openaq_find_sites: Query the OpenAQ API to get all of the low-cost sensors that...

View source: R/openaq.R

openaq_find_sitesR Documentation

Query the OpenAQ API to get all of the low-cost sensors that have reported PM2.5 within a geographic boundary.

Description

Query the OpenAQ API to get all of the low-cost sensors that have reported PM2.5 within a geographic boundary.

Usage

openaq_find_sites(outline_sf, search_radius = 20000, country_id = "US")

Arguments

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.

Value

A data frame of currently reporting stations

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.