Download, parse and enhance hourly timeseries data from OpenAQ and create an object of class `mts_monitor` for use with the AirMonitor package.
OpenAQ_createMonitor(
locations = NULL,
locations_id = NULL,
parameter = c("pm25"),
startdate = NULL,
enddate = NULL,
timezone = "UTC",
applyQC = TRUE,
maxPages = 10,
sleepSeconds = 0.2,
api_key = NULL
)Previously generated locations object containing `id`.
OpenAQ location identifier.
Parameter to use for data. Currently only `"pm25"` is supported.
Start datetime in the requested timezone.
End datetime in the requested timezone.
Olson timezone used to interpret `startdate` and `enddate`.
Logical specifying whether to apply basic QC to invalidate bad data values.
Maximum number of pages to request automatically.
Number of seconds to pause between additional requests.
OpenAQ API key. If `api_key = NULL`, it will be obtained using `getAPIKey("OPENAQ")`.
An AirMonitor package `mts_monitor` object.
# \donttest{
try({
if (interactive()) {
initializeMazamaSpatialUtils()
# NOTE: Read environment vars from .env file with dotenv::load_dot_env()
OPENAQ_API_KEY <- Sys.getenv("OPENAQ_API_KEY")
locations <-
OpenAQ_createLocations(
api_key = OPENAQ_API_KEY,
countryCodes = "US",
stateCodes = "IL",
counties = "Cook",
lookbackDays = 60
)
monitor <-
OpenAQ_createMonitor(
locations = locations,
locations_id = 6207297,
parameter = "pm25",
startdate = "2026-04-01",
enddate = "2026-04-15",
timezone = "America/Chicago",
api_key = OPENAQ_API_KEY
)
monitor %>%
AirMonitor::monitor_timeseriesPlot(shadedNight = TRUE, addAQI = TRUE)
}
}, silent = FALSE)
# }