Downloads raw measurements from OpenAQ for a single location and returns a wide data frame with one column per requested parameter.
OpenAQ location ID.
Specific parameters for which to download data.
Character string specifying the data interval to return.
Desired start datetime as POSIXct.
Desired end datetime as POSIXct.
Maximum number of records to request per page.
Maximum number of pages to request automatically.
Number of seconds to pause between additional requests.
OpenAQ API key.
A data frame with columns `datetime` plus one column for each requested parameter.
For each requested parameter, this function identifies matching sensors at the requested location, downloads all available pages of measurements up to `maxPages`, stacks measurements across sensors, sorts by `datetime`, and deduplicates by keeping the record from the most recently active sensor. The final data frame is created by joining parameter-specific measurement tables by `datetime`.
# \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")
raw_data <-
OpenAQ_downloadRawData(
locations_id = 1370216,
startdate = "2026-04-01",
enddate = "2026-04-15",
api_key = OPENAQ_API_KEY
)
raw_data %>% plot()
}
}, silent = FALSE)
# }