R/pat_downloadParseRawData.R
pat_downloadParseRawData.Rd
Download and parse time series data for a specific sensor_index
.
pat_downloadParseRawData(
api_key = NULL,
sensor_index = NULL,
startdate = NULL,
enddate = NULL,
timezone = "UTC",
average = 0,
fields = PurpleAir_PAT_QC_FIELDS,
baseUrl = "https://api.purpleair.com/v1/sensors"
)
PurpleAir API Read Key. If api_key = NULL
, it
will be obtained using getAPIKey("PurpleAir-read")
.
See MazamaCoreUtils::setAPIKey
.
PurpleAir sensor unique identifier.
Desired start datetime (ISO 8601).
Desired end datetime (ISO 8601).
Olson timezone used to interpret dates.
Temporal averaging in minutes performed by PurpleAir. One of: 0 (raw), 10, 30, 60 (hour), 360, 1440 (day).
Character string with PurpleAir field names for the Get Sensor Data API.
Base URL for the PurpleAir API.
Dataframe of time series PurpleAir data.
# \donttest{
# Fail gracefully if any resources are not available
try({
library(AirSensor2)
# Hourly (uncorrected) PM2.5
pat_raw <-
pat_downloadParseRawData(
api_key = PurpleAir_API_READ_KEY,
sensor_index = "2323",
startdate = "2023-02-01",
enddate = "2023-02-03",
timezone = "UTC",
average = 60,
fields = "pm2.5_atm"
)
head(pat_raw)
}, silent = FALSE)
#> Error in pat_downloadParseRawData(api_key = PurpleAir_API_READ_KEY, sensor_index = "2323", :
#> object 'PurpleAir_API_READ_KEY' not found
# }