get_counties: Get list of county FIPS codes by providing the state codes,...

Description Usage Arguments Value Note Examples

View source: R/prep_aqi.R

Description

Get list of county FIPS codes by providing the state codes, i.e. California = '06'.

Usage

1
get_counties(aqs_api_email, aqs_api_key, state_codes)

Arguments

aqs_api_email

AQS API email

aqs_api_key

AQS API key

state_codes

A vector of standard state codes according to the Federal Information Processing Standard Publication. This is an output of the get_state_code function.

Value

A dataframe of combined, 5 digit state + county FIPS codes ('fips') and their corresponding county names ('name').

Note

The function uses the AQS API to fetch the data from the API endpoints. Use the following service to register as a user: A verification email will be sent to the email account specified. To register using the email address create and request this link (Replace myemail@example.com in the example with your email address.): (https://aqs.epa.gov/data/api/signup?email=myemail@example.com) You then need to set the email and the key in the .Renviron file as follows, i.e. aqs_api_email=myemail@example.com aqs_api_key=testkey1234

AQS AQI has request limits and ToS: (https://aqs.epa.gov/aqsweb/documents/data_api.html#terms). The function intentionally adds a 10 second delay between each call (per year, per county) but pay attention to the limits as the account may be disabled.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
aqs_api_email = Sys.getenv('aqs_api_email')
aqs_api_key = Sys.getenv('aqs_api_key')

state_codes <- get_state_code(aqs_api_email = aqs_api_email,
                              aqs_api_key = aqs_api_key,
                              state_names = c('California', 'New York'))
counties <- get_counties(aqs_api_email = aqs_api_email,
                         aqs_api_key = aqs_api_key,
                         state_codes = state_codes)

## End(Not run)

wildviz documentation built on Aug. 23, 2021, 9:06 a.m.