openaq_find_sites | R Documentation |
Query the OpenAQ API to get all of the low-cost sensors that have reported PM2.5 within a geographic boundary.
openaq_find_sites(outline_sf, search_radius = 20000, country_id = "US")
outline_sf |
A simple features polygon, such as a state, preferably in an appropriate equal area projection |
search_radius |
The search radius in meters of each query. The max allowed by the API is 100,000. However, this will fail for regions with very dense networks, such as the San Francisco Bay Area. The default is 20,000. |
country_id |
A two-letter country code. Default is "US". Note that only one country can be queried at a time. |
A data frame of currently reporting stations
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.