openaq_get_averages: For the sites found with 'openaq_find_sites', download daily...

View source: R/openaq.R

openaq_get_averagesR Documentation

For the sites found with openaq_find_sites, download daily average PM2.5 data from the OpenAQ API

Description

For the sites found with openaq_find_sites, download daily average PM2.5 data from the OpenAQ API

Usage

openaq_get_averages(sites, date_from, date_to)

Arguments

sites

A data frame returned by openaq_find_sites. The relevant fields are id, which is the OpenAQ location id, plus latitude and longitude

date_from

Earliest date to query in character format "YY-mm-dd"

date_to

Latest date to query in character format "YY-mm-dd"

Value

A data frame with daily avereage PM2.5

Examples

ca <- sf::st_read("states_hi_res.shp")
          ca <- dplyr::filter(ca, STATE_NAME == "California")
          ca <- dplyr::select(ca, OBJECTID, STATE_NAME)
          proj_string <- "+proj=aea +lat_1=30 +lat_2=50 +lat_0=40 +lon_0=-125 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs "
          ca_ea <- sf::st_transform(ca, crs = proj_string)
          sites <- openaq_find_sites(ca_ea)
          date_from <- "2021-02-01"
          date_to <- "2021-02-28"
          avgs <- openaq_get_averages(sites, date_from, date_to)

raffscallion/rapidfire documentation built on June 1, 2025, 2:04 p.m.