Download air quality station metadata from the US EPA "AirNow" platform
Source:R/get_airnow_stations.R
get_airnow_stations.RdAirNow is a US EPA nationwide voluntary program which hosts non-validated air quality observation data from stations in the US and many other countries globally.
The AirNow API provides access to daily metadata files for the available stations at that time.
[get_airnow_stations] provides an easy way to retrieve this metadata (typically to determine station id's to pass to [get_airnow_data])
Usage
get_airnow_stations(
date_range = "now",
time_step = "1 days",
use_sf = FALSE,
quiet = FALSE
)Arguments
- date_range
(Optional). A datetime vector (or a character vector with dates in "YYYY-MM-DD HH:MM:SS" format, or "now" for current hour) with either 1 or 2 values. Providing a single value will return data for that hour only, whereas two values will return data between (and including) those times. Dates are "backward-looking", so a value of "2019-01-01 01:00" covers from "2019-01-01 00:01"- "2019-01-01 01:00". Default is "now" (the current hour).
- time_step
(Optional). A character string specifying the time step to check data for within `date_range`. Default is "1 days" (i.e. check every day within `date_range` - may be slow for long date ranges).
- use_sf
(Optional) a single logical (TRUE/FALSE) value indicating whether or not to return a spatial object. using the `sf` package
- quiet
(Optional). A single logical (TRUE or FALSE) value indicating if non-critical messages/warnings should be silenced. Default is FALSE.
See also
[get_airnow_data]
Other Data Collection:
get_abgov_data(),
get_abgov_stations(),
get_airnow_data(),
get_bcgov_data(),
get_bcgov_stations(),
purpleair_api()
Examples
# \donttest{
# Normal usage
get_airnow_stations()
#> # A tibble: 5,128 × 11
#> site_id site_name city lat lng elev status operator tz_offset as_of
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr>
#> 1 84038025… Lake Ilo DUNN 47.3 -103. 684. Active North D… -7 2025…
#> 2 482010057 Galena P… HARR… 29.7 -95.2 8.2 Active Texas C… -6 2025…
#> 3 482011034 Houston … HARR… 29.8 -95.2 6.1 Active Texas C… -6 2025…
#> 4 060659001 Lake Els… RIVE… 33.7 -117. 134. Active South C… -8 2025…
#> 5 040132001 Glendale… MARI… 33.6 -112. 350. Active Maricop… -7 2025…
#> 6 371730007 Eastern … SWAIN 35.5 -83.3 604. Inact… Quality… -5 2025…
#> 7 300630038 Seeley L… MISS… 47.2 -113. 0 Active Montana… -7 2025…
#> 8 060170010 Placervi… EL D… 38.7 -121. 0 Inact… Califor… -8 2025…
#> 9 060792002 San Luis… SAN … 35.3 -121. 0 Inact… Califor… -8 2025…
#> 10 800150131 Atizapán MEXI… 19.6 -99.3 2342. Active Red de … -6 2025…
#> # ℹ 5,118 more rows
#> # ℹ 1 more variable: tz_local <chr>
# if spatial object required
get_airnow_stations(use_sf = TRUE)
#> Simple feature collection with 5128 features and 9 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -161.767 ymin: -34.5766 xmax: 144.36 ymax: 70.1319
#> Geodetic CRS: WGS 84
#> # A tibble: 5,128 × 10
#> site_id site_name city elev status operator tz_offset as_of tz_local
#> * <chr> <chr> <chr> <dbl> <chr> <chr> <dbl> <chr> <chr>
#> 1 840380250004 Lake Ilo DUNN 684. Active North D… -7 2025… America…
#> 2 482010057 Galena Pa… HARR… 8.2 Active Texas C… -6 2025… America…
#> 3 482011034 Houston E… HARR… 6.1 Active Texas C… -6 2025… America…
#> 4 060659001 Lake Elsi… RIVE… 134. Active South C… -8 2025… America…
#> 5 040132001 Glendale … MARI… 350. Active Maricop… -7 2025… America…
#> 6 371730007 Eastern B… SWAIN 604. Inact… Quality… -5 2025… America…
#> 7 300630038 Seeley La… MISS… 0 Active Montana… -7 2025… America…
#> 8 060170010 Placervil… EL D… 0 Inact… Califor… -8 2025… America…
#> 9 060792002 San Luis … SAN … 0 Inact… Califor… -8 2025… America…
#> 10 800150131 Atizapán MEXI… 2342. Active Red de … -6 2025… America…
#> # ℹ 5,118 more rows
#> # ℹ 1 more variable: geometry <POINT [°]>
# if data for some time in the past required
get_airnow_stations(date_range = lubridate::ymd("2022-01-01"))
#> # A tibble: 4,746 × 11
#> site_id site_name city lat lng elev status operator tz_offset as_of
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr>
#> 1 017203140 JPN Site 0… NA 36.4 136. 0 Active Japan M… 9 2022…
#> 2 019321030 JPN Site 0… NA 35.6 139. 0 Active Japan M… 9 2022…
#> 3 020204510 JPN Site 0… NA 36.1 138. 0 Active Japan M… 9 2022…
#> 4 022202150 JPN Site 0… NA 34.7 138. 0 Active Japan M… 9 2022…
#> 5 022447010 JPN Site 0… NA 34.7 138. 0 Active Japan M… 9 2022…
#> 6 028202530 JPN Site 0… NA 34.8 135. 0 Active Japan M… 9 2022…
#> 7 028214510 JPN Site 0… NA 34.8 135. 0 Active Japan M… 9 2022…
#> 8 030205020 JPN Site 0… NA 33.9 135. 0 Active Japan M… 9 2022…
#> 9 033202070 JPN Site 0… NA 34.5 134. 0 Active Japan M… 9 2022…
#> 10 035205030 JPN Site 0… NA 34.0 132. 0 Active Japan M… 9 2022…
#> # ℹ 4,736 more rows
#> # ℹ 1 more variable: tz_local <chr>
# Or a range of time
get_airnow_stations(date_range = lubridate::ymd(c("2022-01-01","2022-01-05")))
#> # A tibble: 4,751 × 11
#> site_id site_name city lat lng elev status operator tz_offset as_of
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr>
#> 1 80011G002 Estación… GUAN… 20.5 -101. 477. Active Secreta… -6 2022…
#> 2 800140009 Loma Dor… JALI… 20.6 -103. 502. Active Sistema… -6 2022…
#> 3 80011G018 Estación… GUAN… 21.0 -101. 610 Active Secreta… -6 2022…
#> 4 150031001 Honolulu HONO… 21.3 -158. 0 Active Hawaii … -10 2022…
#> 5 682RIY010… Riyadh NA 24.7 46.6 0 Active U.S. De… 3 2022…
#> 6 484391062 Kennedal… TARR… 32.7 -97.2 195. Active Texas C… 0 2022…
#> 7 482030002 Karnack … HARR… 32.7 -94.2 0 Active Texas C… -6 2022…
#> 8 060732000 Manzanit… SAN … 32.7 -116. 0 Active Manzani… -8 2022…
#> 9 061000000 NA NA 32.7 -116. 0 Active Manzani… -8 2022…
#> 10 043201520 JPN Site… NA 32.8 131. 0 Active Japan M… 9 2022…
#> # ℹ 4,741 more rows
#> # ℹ 1 more variable: tz_local <chr>
# }