Package 'raqs'

Title: Interface to the US EPA Air Quality System (AQS) API
Description: Offers functions for fetching JSON data from the US EPA Air Quality System (AQS) API with options to comply with the API rate limits. See <https://aqs.epa.gov/aqsweb/documents/data_api.html> for details of the AQS API.
Authors: Jaehyun Joo [aut, cre], Blanca Himes [aut]
Maintainer: Jaehyun Joo <[email protected]>
License: MIT + file LICENSE
Version: 1.0.2
Built: 2024-11-12 04:10:40 UTC
Source: https://github.com/himesgroup/raqs

Help Index


raqs: Interface to the US EPA Air Quality System (AQS) API

Description

Offers functions for fetching JSON data from the US EPA Air Quality System (AQS) API with options to comply with the API rate limits. See https://aqs.epa.gov/aqsweb/documents/data_api.html for details of the AQS API.

Details

The 'raqs' package provides an R interface to the US EPA AQS API that publish data in JSON format. To use this package, you first need to register for the AQS API and get your API key. Please check aqs_signup and set_aqs_user to set up your API credentials in R.

All main functions, for fetching data from the AQS API, were named with the following scheme: ⁠aqs_{service}⁠

Each main function has a set of underlying functions that are responsible for sending requests to specific endpoints (service/filter) and were named with the following scheme: ⁠{service}_{filter}⁠. Please refer to the manual to see how the aforementioned functions work.

Author(s)

Maintainer: Jaehyun Joo [email protected]

Authors:

  • Blanca Himes

See Also

Useful links:


AQS API Annual Summary Data service

Description

A collection of functions to fetch data summarized at the yearly level. Note that only the year portions of the bdate and edate are used and only whole years of data are returned.

Usage

aqs_annualdata(
  aqs_filter = c("bySite", "byCounty", "byState", "byBox", "byCBSA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

annualdata_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

annualdata_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

annualdata_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

annualdata_bybox(
  param,
  bdate,
  edate,
  minlat,
  maxlat,
  minlon,
  maxlon,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

annualdata_bycbsa(
  param,
  bdate,
  edate,
  cbsa,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only the year portion is used.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only the year portion is used. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

duration

(optional) A string specifying the 1-character AQS sample duration code. A list of the duration codes can be obtained via list_durations. Only data reported at this sample duration will be returned.

cbdate

(optional) A string specifying the change begin date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or after this date will be returned.

cedate

(optional) A string specifying the change end date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or before this date will be returned.

minlat

A string or numeric value specifying the minimum latitude of a geographic box. Decimal latitude with north being positive.

maxlat

A string or numeric value specifying the maximum latitude of a geographic box. Decimal latitude with north being positive.

minlon

A string or numeric value specifying the minimum longitude of a geographic box. Decimal longitude with east being positive.

maxlon

A string or numeric value specifying the maximum longitude of a geographic box. Decimal longitude with east being positive.

cbsa

A string specifying the AQS CBSA code. A list of the CBSA codes can be obtained via list_cbsas.

Details

aqs_annualdata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • annualdata_bysite returns annual summary param data for site in county, within state, based on the year portions of bdate and edate.

  • annualdata_bycounty returns annual summary param data for county in state based on the year portions of bdate and edate.

  • annualdata_bystate returns annual summary param data for state based on the year portions of bdate and edate.

  • annualdata_bybox returns annual summary param data for a user-provided latitude/longitude bounding box (minlat, maxlat, minlon, maxlon) based on the year portions of bdate and edate.

  • annualdata_bycbsa returns annual summary param data for a user-provided CBSA based on the year portions of bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## FRM/FEM PM2.5 data for Wake County, NC for 2016
## Only the year portions of bdate and edate are used
aqs_variables <- list(
  param = c("88101", "88502"), bdate = "20160101", edate = "20160228",
  state = "37", county = "183"
)
aqs_annualdata(aqs_filter = "byCounty", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
annualdata_bycounty(
  param = c(88101, 88502), bdate = "20160101", edate = "20160228",
  state = 37, county = 183
)

## End(Not run)

AQS API Daily Summary Data service

Description

A collection of functions to fetch data summarized at the daily level. Please use a narrow range of dates to adhere to the API's limit imposed on request size.

Usage

aqs_dailydata(
  aqs_filter = c("bySite", "byCounty", "byState", "byBox", "byCBSA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

dailydata_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

dailydata_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

dailydata_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

dailydata_bybox(
  param,
  bdate,
  edate,
  minlat,
  maxlat,
  minlon,
  maxlon,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

dailydata_bycbsa(
  param,
  bdate,
  edate,
  cbsa,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

duration

(optional) A string specifying the 1-character AQS sample duration code. A list of the duration codes can be obtained via list_durations. Only data reported at this sample duration will be returned.

cbdate

(optional) A string specifying the change begin date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or after this date will be returned.

cedate

(optional) A string specifying the change end date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or before this date will be returned.

minlat

A string or numeric value specifying the minimum latitude of a geographic box. Decimal latitude with north being positive.

maxlat

A string or numeric value specifying the maximum latitude of a geographic box. Decimal latitude with north being positive.

minlon

A string or numeric value specifying the minimum longitude of a geographic box. Decimal longitude with east being positive.

maxlon

A string or numeric value specifying the maximum longitude of a geographic box. Decimal longitude with east being positive.

cbsa

A string specifying the AQS CBSA code. A list of the CBSA codes can be obtained via list_cbsas.

Details

aqs_dailydata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • dailydata_bysite returns daily summary param data for site in county, within state, between bdate and edate.

  • dailydata_bycounty returns daily summary param data for county in state between bdate and edate.

  • dailydata_bystate returns daily summary param data for state between bdate and edate.

  • dailydata_bybox returns daily summary param data for a user-provided latitude/longitude bounding box (minlat, maxlat, minlon, maxlon) between bdate and edate.

  • dailydata_bycbsa returns daily summary param data for a user-provided CBSA between bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## FRM/FEM PM2.5 data for Wake County, NC between Jan and Feb 2016
aqs_variables <- list(
  param = "88101", bdate = "20160101", edate = "20160228",
  state = "37", county = "183"
)
aqs_dailydata(aqs_filter = "byCounty", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
dailydata_bycounty(
  param = 88101, bdate = "20160101", edate = "20160228",
  state = 37, county = 183
)

## End(Not run)

AQS API List service

Description

A collection of functions to fetch variable values you need to create other service requests. All outputs are a value and the definition of that value.

Usage

aqs_list(
  aqs_filter = c("states", "countiesByState", "sitesByCounty", "cbsas", "classes",
    "parametersByClass", "pqaos", "mas", "durations"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

list_states(email = get_aqs_email(), key = get_aqs_key(), header = FALSE, ...)

list_countiesbystate(
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

list_sitesbycounty(
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

list_cbsas(email = get_aqs_email(), key = get_aqs_key(), header = FALSE, ...)

list_classes(email = get_aqs_email(), key = get_aqs_key(), header = FALSE, ...)

list_parametersbyclass(
  pc,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

list_pqaos(email = get_aqs_email(), key = get_aqs_key(), header = FALSE, ...)

list_mas(email = get_aqs_email(), key = get_aqs_key(), header = FALSE, ...)

list_durations(
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

pc

A string specifying the AQS parameter class name. A list of the class names can be obtained via list_classes.

Details

aqs_list sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • list_states returns a list of the states and their FIPS codes.

  • list_countiesbystate returns a list of all counties within a user-provided state.

  • list_sitesbycounty returns a list of all sites within a user-provided county.

  • list_cbsas returns a list of the 5-digit Core Based Statistical Area (CBSA) codes.

  • list_classes returns a list of parameter class codes.

  • list_parametersbyclass returns all parameters in a user-provided parameter class.

  • list_pqaos returns a list of AQS Primary Quality Assurance Organization (PQAO) codes.

  • list_mas returns a list of AQS Monitoring Agency (MA) codes.

  • list_durations returns a list of the 1-character AQS sample duration codes.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

aqs_list(aqs_filter = "states")
list_states() # equivalent to above

aqs_list("countiesByState", aqs_variables = list(state = "01"))
list_countiesbystate(state = "01")

aqs_list("sitesByCounty", aqs_variables = list(state = "37", county = "183"))
list_sitesbycounty(state = "37", county = "183")

aqs_list("cbsas")
list_cbsas()

aqs_list("classes")
list_classes()

aqs_list("parametersByClass", list(pc = "CRITERIA")) # Criteria pollutants
list_parametersbyclass(pc = "CRITERIA")

aqs_list("pqaos")
list_pqaos()

aqs_list("mas")
list_mas()

aqs_list("durations")
list_durations()

## End(Not run)

AQS API Meta Data service

Description

A collection of functions to fetch information about the AQS API. The main purpose of this service is to let you know the system is up before you run a long job.

Usage

aqs_metadata(
  aqs_filter = c("isAvailable", "revisionHistory", "fieldsByService", "issues"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

metadata_isavailable(...)

metadata_revisionhistory(
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

metadata_fieldsbyservice(
  service,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

metadata_issues(
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

service

A string specifying one of the services available (e.g., sampleData)

Details

aqs_metadata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

aqs_metadata(aqs_filter = "isAvailable")
metadata_isavailable() # equivalent to above

aqs_metadata("revisionHistory")
metadata_revisionhistory()

aqs_metadata("fieldsByService", aqs_variables = list(service = "annualData"))
metadata_fieldsbyservice(service = "annualData")

aqs_metadata("issues")
metadata_issues()

## End(Not run)

AQS API Monitors service

Description

A collection of functions to fetch operational information about the samplers (monitors) used to collect data, including identifying information, operational dates, operating organizations, and etc.

Usage

aqs_monitors(
  aqs_filter = c("bySite", "byCounty", "byState", "byBox", "byCBSA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

monitors_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

monitors_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

monitors_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

monitors_bybox(
  param,
  bdate,
  edate,
  minlat,
  maxlat,
  minlon,
  maxlon,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

monitors_bycbsa(
  param,
  bdate,
  edate,
  cbsa,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

minlat

A string or numeric value specifying the minimum latitude of a geographic box. Decimal latitude with north being positive.

maxlat

A string or numeric value specifying the maximum latitude of a geographic box. Decimal latitude with north being positive.

minlon

A string or numeric value specifying the minimum longitude of a geographic box. Decimal longitude with east being positive.

maxlon

A string or numeric value specifying the maximum longitude of a geographic box. Decimal longitude with east being positive.

cbsa

A string specifying the AQS CBSA code. A list of the CBSA codes can be obtained via list_cbsas.

Details

aqs_monitors sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • monitors_bysite returns param monitors that were operating at site in county, within state, between bdate and edate.

  • monitors_bycounty returns param monitors that were operating in county within state between bdate and edate.

  • monitors_bystate returns param monitors that were operating in state between bdate and edate.

  • monitors_bybox returns param monitors that were operating at a user-provided latitude/longitude bounding box (minlat, maxlat, minlon, maxlon) between bdate and edate.

  • monitors_bycbsa returns param monitors that were operating at a user-provided CBSA between bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## SO2 monitors in Hawaii that were operating on May 01, 2015
aqs_variables <- list(
  param = "42401", bdate = "20150501", edate = "20150502", state = "15"
)
aqs_monitors(aqs_filter = "bySite", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
monitors_bystate(
  param = 42401, bdate = "20150501", edate = "20150502", state = 15
)

## End(Not run)

AQS API QA Annual Performance Evaluations service

Description

A collection of functions to fetch pairs of data (known and measured values) at several concentration levels for gaseous criteria pollutants.

Usage

aqs_qaannualperformanceevaluations(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qaannualperformanceevaluations_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaannualperformanceevaluations_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaannualperformanceevaluations_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaannualperformanceevaluations_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaannualperformanceevaluations_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qaannualperformanceevaluations sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## Annual performance evaluation data for ozone in Alabama during 2017
aqs_variables <- list(
  param = "44201", bdate = "20170101", edate = "20171231",
  state = "01"
)
aqs_qaannualperformanceevaluations(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qaannualperformanceevaluations_bystate(
  param = 44201, bdate = "20170101", edate = "20171231",
  state = 1
)

## End(Not run)

AQS API QA Blanks Data service

Description

A collection of functions to fetch the concentration of from blank samples.

Usage

aqs_qablanks(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qablanks_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qablanks_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qablanks_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qablanks_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qablanks_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only the year portion is used.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only the year portion is used. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qablanks sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • qablanks_bysite returns param blank data for site in county, within state, between bdate and edate.

  • qablanks_bycounty returns param blank data for county in state between bdate and edate.

  • qablanks_bystate returns param blank data for state between bdate and edate.

  • qablanks_bypqao returns param blank data for pqao between bdate and edate.

  • qablanks_byma returns param blank data for agency (monitoring agency) between bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## PM2.5 blank data for Alabama for January 2018
aqs_variables <- list(
  param = "88101", bdate = "20180101", edate = "20180131",
  state = "01"
)
aqs_qablanks(aqs_filter = "byState", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
qablanks_bystate(
  param = 88101, bdate = "20180101", edate = "20180131",
  state = 1
)

## End(Not run)

AQS API QA Collocated Assessments service

Description

A collection of functions to fetch pairs of PM samples collected at the same time and place by different samplers.

Usage

aqs_qacollocatedassessments(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qacollocatedassessments_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qacollocatedassessments_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qacollocatedassessments_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qacollocatedassessments_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qacollocatedassessments_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qacollocatedassessments sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## Collocated assessment data for FRM PM2.5 in Alabama for January 2013
aqs_variables <- list(
  param = "88101", bdate = "20130101", edate = "20130131",
  state = "01"
)
aqs_qacollocatedassessments(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qacollocatedassessments_bystate(
  param = 88101, bdate = "20130101", edate = "20130131",
  state = 1
)

## End(Not run)

AQS API QA Flow Rate Audits service

Description

A collection of functions to fetch flow rate audit data.

Usage

aqs_qaflowrateaudits(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qaflowrateaudits_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateaudits_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateaudits_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateaudits_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateaudits_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qaflowrateaudits sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## Flow rate audit data for Alabama during January 2018
aqs_variables <- list(
  param = "88101", bdate = "20180101", edate = "20180131",
  state = "01"
)
aqs_qaflowrateaudits(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qaflowrateaudits_bystate(
  param = 88101, bdate = "20180101", edate = "20180131",
  state = 1
)

## End(Not run)

AQS API QA Flow Rate Verifications service

Description

A collection of functions to fetch flow rate checks performed by monitoring agencies.

Usage

aqs_qaflowrateverifications(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qaflowrateverifications_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateverifications_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateverifications_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateverifications_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaflowrateverifications_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qaflowrateverifications sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## Flow Rate Verification data for Alabama during January 2018
aqs_variables <- list(
  param = "88101", bdate = "20180101", edate = "20180131",
  state = "01"
)
aqs_qaflowrateverifications(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qaflowrateverifications_bystate(
  param = 88101, bdate = "20180101", edate = "20180131",
  state = 1
)

## End(Not run)

AQS API QA One Point QC Raw Data service

Description

A collection of functions to fetch measured versus actual concentration of 1 point QC checks.

Usage

aqs_qaonepointqcrawdata(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qaonepointqcrawdata_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaonepointqcrawdata_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaonepointqcrawdata_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaonepointqcrawdata_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qaonepointqcrawdata_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qaonepointqcrawdata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## One Point QC data for ozone in Massachusetts for January 2018
aqs_variables <- list(
  param = "44201", bdate = "20180101", edate = "20180131",
  state = "25"
)
aqs_qaonepointqcrawdata(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qaonepointqcrawdata_bystate(
  param = 44201, bdate = "20180101", edate = "20180131",
  state = 25
)

## End(Not run)

AQS API QA PEP Audits service

Description

A collection of functions to fetch data related to PM2.5 monitoring system audits.

Usage

aqs_qapepaudits(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

qapepaudits_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qapepaudits_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qapepaudits_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qapepaudits_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

qapepaudits_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_qapepaudits sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • qapepaudits_bysite returns PEP Audit data for param at site in county, within state, between bdate and edate.

  • qapepaudits_bycounty returns PEP Audit data for param in county within state between bdate and edate.

  • qapepaudits_bystate returns PEP Audit data for param in state between bdate and edate.

  • qapepaudits_bypqao returns PEP Audit data for param in pqao between bdate and edate.

  • qapepaudits_byma returns PEP Audit data for param in agency (monitoring agency) between bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## PEP Audit data for FRM PM2.5 in Alabama for 2017
aqs_variables <- list(
  param = "88101", bdate = "20170101", edate = "20171231",
  state = "01"
)
aqs_qapepaudits(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
qapepaudits_bystate(
  param = 88101, bdate = "20170101", edate = "20171231",
  state = 1
)

## End(Not run)

AQS API Quarterly Summary Data service

Description

A collection of functions to fetch data summarized at the calendar quarter level. Data is labeled with quarter number (Q1 = Jan - Mar, Q2 = Apr - Jun, Q3 = Jul - Sep, Q4 = Oct - Dec). Note that only the year portion of the bdate and edate are used and all 4 quarters in the year are returned. In addition, duration is not allowed on the API unlike aqs_sampledata, aqs_dailydata, and aqs_annualdata.

Usage

aqs_quarterlydata(
  aqs_filter = c("bySite", "byCounty", "byState", "byBox", "byCBSA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

quarterlydata_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

quarterlydata_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

quarterlydata_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

quarterlydata_bybox(
  param,
  bdate,
  edate,
  minlat,
  maxlat,
  minlon,
  maxlon,
  email = get_aqs_email(),
  key = get_aqs_key(),
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

quarterlydata_bycbsa(
  param,
  bdate,
  edate,
  cbsa,
  email = get_aqs_email(),
  key = get_aqs_key(),
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only the year portion is used.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only the year portion is used. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

cbdate

(optional) A string specifying the change begin date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or after this date will be returned.

cedate

(optional) A string specifying the change end date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or before this date will be returned.

minlat

A string or numeric value specifying the minimum latitude of a geographic box. Decimal latitude with north being positive.

maxlat

A string or numeric value specifying the maximum latitude of a geographic box. Decimal latitude with north being positive.

minlon

A string or numeric value specifying the minimum longitude of a geographic box. Decimal longitude with east being positive.

maxlon

A string or numeric value specifying the maximum longitude of a geographic box. Decimal longitude with east being positive.

cbsa

A string specifying the AQS CBSA code. A list of the CBSA codes can be obtained via list_cbsas.

Details

aqs_quarterlydata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • quarterlydata_bysite returns quarterly summary param data for site in county, within state, based on the year portions of bdate and edate.

  • quarterlydata_bycounty returns quarterly summary param data for county in state based on the year portions bdate and edate.

  • quarterlydata_bystate returns quarterly summary param data for state based on the year portions of bdate and edate.

  • quarterlydata_bybox returns quarterly summary param data for a user-provided latitude/longitude bounding box (minlat, maxlat, minlon, maxlon) based on the year portions of bdate and edate.

  • quarterlydata_bycbsa returns quarterly summary param data for a user-provided CBSA based on the year portions of bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## FRM/FEM PM2.5 data for Wake County, NC for 2016
## Only the year portions of bdate and edate are used
aqs_variables <- list(
  param = c("88101", "88502"), bdate = "20160101", edate = "20160228",
  state = "37", county = "183"
)
aqs_quarterlydata(aqs_filter = "byCounty", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
quarterlydata_bycounty(
  param = c(88101, 88502), bdate = "20160101", edate = "20160228",
  state = 37, county = 183
)

## End(Not run)

AQS API Sample Data service

Description

A collection of functions to fetch sample data - the finest grain data reported to EPA. Please use a narrow range of dates to adhere to the API's limit imposed on request size.

Usage

aqs_sampledata(
  aqs_filter = c("bySite", "byCounty", "byState", "byBox", "byCBSA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

sampledata_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

sampledata_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

sampledata_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

sampledata_bybox(
  param,
  bdate,
  edate,
  minlat,
  maxlat,
  minlon,
  maxlon,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

sampledata_bycbsa(
  param,
  bdate,
  edate,
  cbsa,
  email = get_aqs_email(),
  key = get_aqs_key(),
  duration = NULL,
  cbdate = NULL,
  cedate = NULL,
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

duration

(optional) A string specifying the 1-character AQS sample duration code. A list of the duration codes can be obtained via list_durations. Only data reported at this sample duration will be returned.

cbdate

(optional) A string specifying the change begin date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or after this date will be returned.

cedate

(optional) A string specifying the change end date in YYYYMMDD format to subset data based on "date of last change" in database. Only data that changed on or before this date will be returned.

minlat

A string or numeric value specifying the minimum latitude of a geographic box. Decimal latitude with north being positive.

maxlat

A string or numeric value specifying the maximum latitude of a geographic box. Decimal latitude with north being positive.

minlon

A string or numeric value specifying the minimum longitude of a geographic box. Decimal longitude with east being positive.

maxlon

A string or numeric value specifying the maximum longitude of a geographic box. Decimal longitude with east being positive.

cbsa

A string specifying the AQS CBSA code. A list of the CBSA codes can be obtained via list_cbsas.

Details

aqs_sampledata sends a request to the AQS API based on a user-provided filter using the following underlying functions:

  • sampledata_bysite returns all param samples for site in county, within state, between bdate and edate.

  • sampledata_bycounty returns all param samples for county in state between bdate and edate.

  • sampledata_bystate returns all param samples for state between bdate and edate.

  • sampledata_bybox returns all param samples for a user-provided latitude/longitude bounding box (minlat, maxlat, minlon, maxlon) between bdate and edate.

  • sampledata_bycbsa returns all param samples for a user-provided CBSA between bdate and edate.

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## FRM/FEM PM2.5 data for Wake County, NC between Jan and Feb 2016
aqs_variables <- list(
  param = "88101", bdate = "20160101", edate = "20160228",
  state = "37", county = "183"
)
aqs_sampledata(aqs_filter = "byCounty", aqs_variables = aqs_variables)

## Equivalent to above; used integers instead of strings
sampledata_bycounty(
  param = 88101, bdate = "20160101", edate = "20160228",
  state = 37, county = 183
)

## End(Not run)

Create an account for the AQS API

Description

This function helps you create an account or reset a password. Once you execute this function, a verification email will be sent to the email account specified. If the request is made with an email that is already registered, a new key will be issued for that account and emailed to the listed address.

Usage

aqs_signup(email)

Arguments

email

A string specifying an email account to register as a user

Value

No return value, called to sign up for the AQS API

See Also

See set_aqs_user to set your credentials to send a request to the AQS API.

Examples

## Not run: 

## Please use your email address to create an account

aqs_signup(email = "[email protected]")

## End(Not run)

AQS API QA Annual Performance Evaluations Transaction service

Description

A collection of functions to fetch pairs of data QA at several concentration levels in the submission (transaction) format for AQS.

Usage

aqs_transactionsqaannualperformanceevaluations(
  aqs_filter = c("bySite", "byCounty", "byState", "byPQAO", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

transactionsqaannualperformanceevaluations_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionsqaannualperformanceevaluations_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionsqaannualperformanceevaluations_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionsqaannualperformanceevaluations_bypqao(
  param,
  bdate,
  edate,
  pqao,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionsqaannualperformanceevaluations_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

pqao

A string specifying the AQS Primary Quality Assurance Organization (PQAO) code. A list of the PQAO codes can be obtained via list_pqaos.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_transactionsqaannualperformanceevaluations sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## Annual performance evaluation data for ozone in Alabama during 2017
aqs_variables <- list(
  param = "44201", bdate = "20170101", edate = "20171231",
  state = "01"
)
aqs_transactionsqaannualperformanceevaluations(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
transactionsqaannualperformanceevaluations_bystate(
  param = 44201, bdate = "20170101", edate = "20171231",
  state = 1
)

## End(Not run)

AQS API Sample Data Transaction service

Description

A collection of functions to fetch data in the submission (transaction) format for AQS.

Usage

aqs_transactionssample(
  aqs_filter = c("bySite", "byCounty", "byState", "byMA"),
  aqs_variables = NULL,
  header = FALSE,
  ...
)

transactionssample_bysite(
  param,
  bdate,
  edate,
  state,
  county,
  site,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionssample_bycounty(
  param,
  bdate,
  edate,
  state,
  county,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionssample_bystate(
  param,
  bdate,
  edate,
  state,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

transactionssample_byma(
  param,
  bdate,
  edate,
  agency,
  email = get_aqs_email(),
  key = get_aqs_key(),
  header = FALSE,
  ...
)

Arguments

aqs_filter

A string specifying one of the service filters. NOT case-sensitive.

aqs_variables

A named list of variables to fetch data (e.g., state). Only necessary variables are passed to a specific endpoint (service/filter) to make a valid request.

header

A logical specifying whether the function returns additional information from the API header. Default is FALSE to return data only.

...

Reserved for future use.

param

A string or vector of strings specifying the 5-digit AQS parameter code for data selection. An integer will be coerced to a string. A maximum of 5 parameter codes may be listed in a single request. A list of the parameter codes can be obtained via list_parametersbyclass.

bdate

A string specifying the begin date of data selection in YYYYMMDD format. Only data on or after this date will be returned.

edate

A string specifying the end date of data selection in YYYYMMDD format. Only data on or before this date will be returned. If the end date is not in the same year as the begin date, the function will automatically split the date range into multiple chunks by year and send requests sequentially.

state

A string specifying the 2-digit state FIPS code. An integer will be coerced to a string with a leading zero if necessary (e.g., 1 -> "01"). A list of the state codes can be obtained via list_states.

county

A string specifying the 3-digit county FIPS code. An integer will be coerced to a string with leading zeros if necessary (e.g., 89 -> "089"). A list of the county codes within each state can be obtained via list_countiesbystate.

site

A string specifying the 4-digit AQS site number within the county. An integer will be coerced to a string with leading zeros if necessary (e.g., 14 -> "0014"). A list of the site codes within each county can be obtained via list_sitesbycounty.

email

A string specifying the email address of the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

key

A string specifying the key matching the email address for the requester. If you set your email and key with set_aqs_user, you don't have to specify this.

agency

A string specifying the AQS Monitoring Agency (MA) code. A list of the MA codes can be obtained via list_mas. Here, we named this input as agency instead of "ma" because agency is actually used in the API endpoint URL.

Details

aqs_transactionssample sends a request to the AQS API based on a user-provided filter using the following underlying functions:

Value

A data.frame containing parsed data or a named list containing header and data.

Examples

## Not run: 

## Set your API Key first using set_aqs_user to run the following codes

## Example from the AQS website
## all benzene samples from North Carolina collected on May 15th, 1995
aqs_variables <- list(
  param = "45201", bdate = "19950515", edate = "19950515",
  state = "37"
)
aqs_transactionssample(
  aqs_filter = "byState", aqs_variables = aqs_variables
)

## Equivalent to above; used integers instead of strings
transactionssample_bystate(
  param = 45201, bdate = "19950515", edate = "19950515",
  state = 37
)

## End(Not run)

Package options

Description

The following package options can be set via options and queried via getOption.

Options to handle the AQS API rate limits

The AQS API recommends not to make more than 10 requests per minute and pause 5 seconds between requests.

  • raqs.req_per_min controls the maximum number of API requests per minute. Default is 10.

  • raqs.delay_between_req controls a delay between API requests sent via a function when your bdate and edate inputs span multiple years. A value will be rounded to the nearest integer. Default is 5 seconds.

  • raqs.delay_fun_exit controls a delay before a function execution ends. A value will be rounded to the nearest integer. Default is zero if R is being used interactively. Otherwise, it is 5 seconds. This option only applies to functions that send API requests.

Option to handle the type of data object to return

By default, the parsed data will be returned as a data.frame object, but can be adjusted for users' preferences.

  • raqs.return_type controls the type of data object to return. Default is "data.frame" but it can also be set to "tibble" or "data.table".

Examples

## Change for the duration of the session
op <- options(raqs.rep_per_min = 5)

## Change back to the original value
options(op)

Set your AQS API credentials

Description

Set your registered email and key as environmental variables for the current session. Please sign up first using aqs_signup if you haven't set up an account on the AQS API. If you want to set your email and key permanently, please add the following lines in your .Renviron file:

  • AQS_EMAIL = YOUR REGISTERED EMAIL

  • AQS_KEY = YOUR API KEY

Usage

set_aqs_user(email, key)

get_aqs_user()

get_aqs_email()

get_aqs_key()

Arguments

email

A string specifying your registered email address

key

A string specifying your API key

Details

set_aqs_user sets your API credentials for the current session. get_aqs_user, get_aqs_email, and get_aqs_key are helper functions to display saved user values.

Value

No return value, called to set environmental variables

See Also

See aqs_signup to create an account for the AQS API

Examples

## Please use your registered email and key
set_aqs_user(email = "[email protected]", key = "your_api_key")

## Show your API credentials
get_aqs_user() # return list(email, key)
get_aqs_email() # return email
get_aqs_key() # return key