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 = AIRSENSOR_1_PAT_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(AirSensor)
initializeMazamaSpatialUtils()
pat_raw <-
pat_downloadParseRawData(
api_key = PURPLE_AIR_API_READ_KEY,
sensor_index = "2323",
startdate = "2023-02-01",
enddate = "2023-02-02",
timezone = "UTC"
)
View(pat_raw[1:100,])
}, silent = FALSE)
#> Error in pat_downloadParseRawData(api_key = PURPLE_AIR_API_READ_KEY, sensor_index = "2323", :
#> object 'PURPLE_AIR_API_READ_KEY' not found
# }