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
)

Arguments

locations

Previously generated locations object containing `id`.

locations_id

OpenAQ location identifier.

parameter

Parameter to use for data. Currently only `"pm25"` is supported.

startdate

Start datetime in the requested timezone.

enddate

End datetime in the requested timezone.

timezone

Olson timezone used to interpret `startdate` and `enddate`.

applyQC

Logical specifying whether to apply basic QC to invalidate bad data values.

maxPages

Maximum number of pages to request automatically.

sleepSeconds

Number of seconds to pause between additional requests.

api_key

OpenAQ API key. If `api_key = NULL`, it will be obtained using `getAPIKey("OPENAQ")`.

Value

An AirMonitor package `mts_monitor` object.

Examples

# \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)
# }