Title: | Retrieve 'AirNow' Air Quality Observations and Forecasts |
---|---|
Description: | Retrieve air quality data via the 'AirNow' <https://www.airnow.gov/> API. |
Authors: | Brian Connelly [aut, cre, cph] |
Maintainer: | Brian Connelly <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-11-21 06:21:34 UTC |
Source: | https://github.com/briandconnelly/airnow |
aqi_color()
returns the color that corresponds with the given
AQI value.
aqi_descriptor()
converts the given AQI value(s) into a
descriptive string.
aqi_color(aqi) aqi_descriptor(aqi)
aqi_color(aqi) aqi_descriptor(aqi)
aqi |
An AQI value. AQI is an integer between 0 and 500, inclusive. |
aqi_color()
returns an RGB hex string
aqi_descriptor()
returns a string
aqi_color(35) aqi_descriptor(35)
aqi_color(35) aqi_descriptor(35)
get_airnow_area()
retrieves the most recent air quality readings from sites
in a specified region.
get_airnow_area( box, parameters = "pm25", start_time = NULL, end_time = NULL, monitor_type = "both", data_type = c("aqi", "concentrations", "both"), verbose = FALSE, raw_concentrations = FALSE, clean_names = TRUE, api_key = get_airnow_token() )
get_airnow_area( box, parameters = "pm25", start_time = NULL, end_time = NULL, monitor_type = "both", data_type = c("aqi", "concentrations", "both"), verbose = FALSE, raw_concentrations = FALSE, clean_names = TRUE, api_key = get_airnow_token() )
box |
Four-element numeric vector specifying a bounding box for the region of interest. Format is (minX, minY, maxX, maxY), where X and Y are longitude and latitude, respectively. |
parameters |
Parameter(s) to return data for. Choices are PM_2.5
( |
start_time |
Optional. The date and time (UTC) at the start of the time
period requested. If specified, |
end_time |
Optional. The date and time (UTC) at the end of the time
period requested. If specified, |
monitor_type |
Type of monitor to be returned, either |
data_type |
Type of data to be returned, either |
verbose |
Logical value indicating whether or not to include additional
site information including Site Name, Agency Name, AQS ID, and Full AQS ID
(default: |
raw_concentrations |
Logical value indicating whether or not raw
hourly concentration data should be included (default: |
clean_names |
Whether or not column names should be cleaned (default:
|
api_key |
AirNow API key |
A data frame with current air quality conditions
## Not run: # Get air quality data around Washington state get_airnow_area(box = c(-125.394211, 45.295897, -116.736984, 49.172497)) ## End(Not run)
## Not run: # Get air quality data around Washington state get_airnow_area(box = c(-125.394211, 45.295897, -116.736984, 49.172497)) ## End(Not run)
get_airnow_conditions()
retrieves the most recent air quality readings
for the given location. Locations can be specified either by ZIP code
(zip
), or by latitude
/longitude
. If no data exist for the specified
location, an optional search radius for other sites can be specified using
distance
.
get_airnow_conditions( zip = NULL, latitude = NULL, longitude = NULL, distance = NULL, clean_names = TRUE, api_key = get_airnow_token() )
get_airnow_conditions( zip = NULL, latitude = NULL, longitude = NULL, distance = NULL, clean_names = TRUE, api_key = get_airnow_token() )
zip |
ZIP code, a 5-digit numeric string (e.g., |
latitude |
Latitude in decimal degrees |
longitude |
Longitude in decimal degrees |
distance |
Optional. If no reporting area is associated with the given
|
clean_names |
Whether or not column names should be cleaned (default:
|
api_key |
AirNow API key |
A data frame with current air quality conditions
## Not run: get_airnow_conditions(zip = "90210") ## End(Not run)
## Not run: get_airnow_conditions(zip = "90210") ## End(Not run)
get_airnow_forecast()
retrieves forecasted air quality conditions
for the given location. Locations can be specified either by ZIP code
(zip
), or by latitude
/longitude
. If no data exist for the specified
location, an optional search radius for other sites can be specified using
distance
.
get_airnow_forecast( zip = NULL, latitude = NULL, longitude = NULL, distance = NULL, date = NULL, clean_names = TRUE, api_key = get_airnow_token() )
get_airnow_forecast( zip = NULL, latitude = NULL, longitude = NULL, distance = NULL, date = NULL, clean_names = TRUE, api_key = get_airnow_token() )
zip |
ZIP code, a 5-digit numeric string (e.g., |
latitude |
Latitude in decimal degrees |
longitude |
Longitude in decimal degrees |
distance |
Optional. If no reporting area is associated with the given
|
date |
Optional date of forecast. If this is not specified, the current forecast is returned. |
clean_names |
Whether or not column names should be cleaned (default:
|
api_key |
AirNow API key |
A data frame with current air quality conditions
## Not run: get_airnow_forecast(zip = "90210") ## End(Not run)
## Not run: get_airnow_forecast(zip = "90210") ## End(Not run)
get_airnow_token()
returns the configured AirNow API token or
errors if it is not set.
set_airnow_token()
sets the AirNow API token to the given
value for the current session. To use this permanently, save it as
AIRNOW_API_KEY
in your ~/.Renviron
file.
get_airnow_token(ask = is_interactive()) set_airnow_token(token = NULL, ask = is_interactive())
get_airnow_token(ask = is_interactive()) set_airnow_token(token = NULL, ask = is_interactive())
ask |
Whether or not to ask for the key if none is provided. Note that this only works for interactive sessions. |
token |
Token to use |
get_airnow_token()
returns a string containing the current
user or group key or an empty string if not set. If the user is not set but
ask
is TRUE
, the user will be prompted for a key.
## Not run: get_airnow_token() ## End(Not run) ## Not run: set_airnow_token(token = "4d36e978-e325-11cec1-08002be10318") ## End(Not run)
## Not run: get_airnow_token() ## End(Not run) ## Not run: set_airnow_token(token = "4d36e978-e325-11cec1-08002be10318") ## End(Not run)