Movatterモバイル変換


[0]ホーム

URL:


Introduction to the RAQSAPI package

Clinton Mccrowey

United States Environmental Protection Agency (US EPA),
Region III,
Air and Radiation Division,
Air Quality and Analysis Branch

Abstract

RAQSAPI is a package for R that connects the R programming languageenvironment to the United States Environmental Protection Agency’s (USEPA) Air Quality System (AQS) Data Mart database API for retrieval ofambient air pollution data.

RAQSAPI hexsticker

EPA Disclaimer

This software/application was developed by the U.S. EnvironmentalProtection Agency (USEPA). No warranty expressed or implied is maderegarding the accuracy or utility of the system, nor shall the act ofdistribution constitute any such warranty. The USEPA has relinquishedcontrol of the information and no longer has responsibility to protectthe integrity, confidentiality or availability of the information. Anyreference to specific commercial products, processes, or services byservice mark, trademark, manufacturer, or otherwise, does not constituteor imply their endorsement, recommendation or favoring by the USEPA. TheUSEPA seal and logo shall not be used in any manner to imply endorsementof any commercial product or activity by the USEPA or the United StatesGovernment.

Warning: US EPA’s AQS Data Mart API V2 iscurrently
in beta phase of development, the API interface has not beenfinalized.
This means that certain functionality of the API may change or beremoved
without notice. As a result, this package is also currently marked asbeta and
may also change to reflect any changes made to the Data Mart API or inrespect
to improvements in the design, functionality, quality and documentationof
this package. The authors assume no liability for any problems that mayoccur
as a result of using this package, the Data Mart service, anysoftware,
service, hardware, or user accounts that may utilize this package.

Introduction

TheRAQSAPI package for the R programming environmentallows a R programming environment to connect to and retrieve data fromthe United States Environmental Protection Agency’s (US EPA) Air QualitySystem (AQS) Data Mart API v2 Air Quality System1 interface directly. This packageenables the data user to omit legacy challenges including coercing datafrom a JSON object to a usable R object, retrieving multiple years ofdata, formatting API requests, retrieving results, handling credentials,requesting multiple pollutant data and rate limiting data requests. Allthe basic functionality of the API have been implemented that areavailable from the AQS API Data Mart server. The library connects to AQSData Mart API via Secure Hypertext Transfer Protocol (HTTPS) so there isno need to install external ODBC drivers, configure ODBC connections ordeal with the security vulnerabilities associated with them. Most APIfunctions have a parameter, return_header, which by default is set toFALSE. If the user decides to set return_header to TRUE, then thatfunction will return a R AQS_DATAMART_APIv2 S3 object which is a twoitem named list.
The first item, ($Header) in the AQS_DATAMART_APIv2 object is atibble2 which contains theheader information. The Header contains status information regarding therequest (success/fail), any applicable error messages returned from theAPI, if any exist, the URL used in the request, a date and time stampnoting when request was received and other useful information. Thesecond item of the AQS_DATAMART_APIv2 object ($Data) is a tibble whichcontains the actual data being requested. For functions with thereturn_header option set to FALSE (default) a simple tibble is returnedwith just the $Data portion of the request. After each call to the API afive second stall is invoked to help prevent overloading the Data MartAPI server and to serve as a simple rate limit.
1

About the timeliness of AQS Data

EPA’s AQS Datamart API, the service that RAQSAPI retrieves data from,does not host real time (collected now/today) data. If real time data isneeded, please use the AirNow API and direct all questions toward realtime data there. RAQSAPI does not work with AirNow and cannot retrievereal time data. For more details see section 7.1 of the About AQS Datapage3.

Installing RAQSAPI

Either install the stable version from CRAN or install the latestdevelopment version from GitHub.

Option 1: Installing the stable version from CRAN

install.packages(pkgs="RAQSAPI",dependencies =TRUE )

Option 2: Installing the development version of RAQSAPI

To install the development version ofRAQSAPI, first ifnot already installed, install theremotes package and itsdependencies. Then run the following in a R environment.

remotes::install_github(repo ="USEPA/raqsapi",dependencies =TRUE,upgrade ="always",build =TRUE,#optional, set TRUE if the manual is desired,#requires pandocbuild_manual =FALSE,build_vignettes =TRUE                        )

Using The RAQSAPI library

Load RAQSAPI

after successfully installing theRAQSAPI package, loadtheRAQSAPI library:

library(RAQSAPI)

Sign up and setting up user credentials with the RAQSAPIlibrary

If you have not already done so you will need to sign up with AQSData Mart using aqs_sign_up function,2 this function takesone input, “email”, which is a R character object, that represents theemail address that you want to use as a user credential to the AQS DataMart service. After a successful call to aqs_sign_up an email messagewill be sent to the email address provided with a new Data Mart keywhich will be used as a credential key to access the Data Mart API. Theaqs_sign_up function can also be used to regenerate a new key for anexisting user, to generate a new key simply call the aqs_sign_upfunction with the parameter “email” set to an existing account. A newkey will be e-mailed to the account given.

The credentials used to access the Data Mart API service are storedin a R environment variable that needs to be set every time theRAQSAPI library is attached or the key is changed. Withoutvalid credentials, the Data Mart server will reject any request sent toit. The key used with Data Mart is a key and is not a password, so theRAQSAPI library does not treat the key as a password; this means thatthe key is stored in plain text and there are no attempts to encryptData Mart credentials as would be done for a username and passwordcombination. The key that is supplied to use with Data Mart is notintended for authentication but only account monitoring. Each timeRAQSAPI is loaded and before using any of it’s functions use theaqs_credentials3 function to enter in the user credentialsso that RAQSAPI can access the AQS Data Mart server.

Note: The credentials used to access AQSData Mart
API is not the same as the credentials used to access AQS. AQS users whodo
not have access to the AQS Data Mart will need to create newcredentials.

(suggested) Use thekeyring package to managecredentials

It is highly suggested that users use a keyring manager to store andretrieve their credentials while using RAQSAPI. One such credentialmanager is provided by thekeyring package4. TheKeyring package uses the credential manager available formost popular operating systems to store and manage user credentials.This will help avoid hard coding credential information into Rscripts.

To use thekeyring package withRAQSAPIfirst installkeyring:

install.package("keyring")

Ensure that your system is supported by thekeyringpackage before proceeding.

  keyring::has_keyring_support()

then set the keyring used to access AQS Data Mart (make sure toreplace the text in the angled brackets with your specific userinformation):

library("keyring")  keyring::key_set(service ="AQSDatamart",username ="\<user email account\>")

a popup window will appear for the user to input their keyringinformation. Enter the AQS Data mart credential key associated with theAQS user name provided, then hit enter. Now the AQS Data Mart usercredential is set usingkeyring.

To retrieve the keyring to use withRAQSAPI load thekeyring package and use the function key_get to return theuser credential to RAQSAPI:

library(RAQSAPI)library(keyring)  datamartAPI_user<- \<user email account\>  server<-"AQSDatamart"

then pass these variables to the aqs_credentials function when usingRAQSAPI:

aqs_credentials(username = datamartAPI_user,key =key_get(service = server,username = datamartAPI_user                                )                  )

To change the keyring stored with thekeyring packagerepeat the steps above to call the keyring::key_set function again withthe new credential information.

To retrieve a list of all keyrings managed with thekeyring package use the function: >keyring::key_list()

Refer the thekeyringpackage documentation for an in depth explanation on using thekeyring package.

Usage tips and precautions

This section contains suggestions for completing certain data relatedtasks.

The AQS Data Mart administrators may disable accounts withoutnotice for failure to adhere to these terms (Though they will contactthe offending user via the email address provided)

RAQSAPI functions

The RAQSAPI library exports the following functions (in alphabeticalorder):

aqs_annualsummary_by_box  aqs_annualsummary_by_cbsa  aqs_annualsummary_by_county  aqs_annualsummary_by_site  aqs_annualsummary_by_state  aqs_cbsas  aqs_classes  aqs_counties_by_state  aqs_credentials  aqs_dailysummary_by_box  aqs_dailysummary_by_cbsa  aqs_dailysummary_by_county  aqs_dailysummary_by_site  aqs_dailysummary_by_state  aqs_fields_by_service  aqs_isavailable  aqs_knownissues  aqs_mas  aqs_monitors_by_box  aqs_monitors_by_cbsa  aqs_monitors_by_county  aqs_monitors_by_site  aqs_monitors_by_state  aqs_parameters_by_class  aqs_pqaos  aqs_qa_annualperformanceeeval_by_county  aqs_qa_annualperformanceeval_by_MA  aqs_qa_annualperformanceeval_by_pqao  aqs_qa_annualperformanceeval_by_site  aqs_qa_annualperformanceeval_by_state  aqs_qa_annualperformanceevaltransaction_by_county  aqs_qa_annualperformanceevaltransaction_by_MA  aqs_qa_annualperformanceevaltransaction_by_pqao  aqs_qa_annualperformanceevaltransaction_by_site  aqs_qa_annualperformanceevaltransaction_by_state  aqs_qa_blanks_by_county  aqs_qa_blanks_by_MA  aqs_qa_blanks_by_pqao  aqs_qa_blanks_by_site  aqs_qa_blanks_by_state  aqs_qa_collocated_assessments_by_county  aqs_qa_collocated_assessments_by_MA  aqs_qa_collocated_assessments_by_pqao  aqs_qa_collocated_assessments_by_site  aqs_qa_collocated_assessments_by_state  aqs_qa_flowrateaudit_by_county  aqs_qa_flowrateaudit_by_MA  aqs_qa_flowrateaudit_by_pqao  aqs_qa_flowrateaudit_by_site  aqs_qa_flowrateaudit_by_state  aqs_qa_flowrateverification_by_county  aqs_qa_flowrateverification_by_MA  aqs_qa_flowrateverification_by_pqao  aqs_qa_flowrateverification_by_site  aqs_qa_flowrateverification_by_state  aqs_qa_one_point_qc_by_county  aqs_qa_one_point_qc_by_MA  aqs_qa_one_point_qc_by_pqao  aqs_qa_one_point_qc_by_site  aqs_qa_one_point_qc_by_state  aqs_qa_pep_audit_by_county  aqs_qa_pep_audit_by_MA  aqs_qa_pep_audit_by_pqao  aqs_qa_pep_audit_by_site  aqs_qa_pep_audit_by_state  aqs_quarterlysummary_by_box  aqs_quarterlysummary_by_county  aqs_quarterlysummary_by_pqao  aqs_quarterlysummary_by_site  aqs_quarterlysummary_by_state  aqs_removeheader  aqs_revisionhistory  aqs_sampledata_by_box  aqs_sampledata_by_cbsa  aqs_sampledata_by_county  aqs_sampledata_by_site  aqs_sampledata_by_state  aqs_sampledurations  aqs_sign_up  aqs_sites_by_county  aqs_states  aqs_transactionsample_by_county  aqs_transactionsample_by_site  aqs_transactionsample_by_state  aqs_transactionsample_by_MA

RAQSAPI functions are named according to the service and filtervariables that are available by the AQS Data Mart API.5

Variable descriptions and usage.

These are all the available variables that can be used with variousfunctions exported from the RAQSAPI library listed alphabetically. Notall of these variables are used with every function, and not all ofthese parameters are required. See theRAQSAPI functional familiessection to see which parameters are used with each function.

RAQSAPI functional families

Sign up and credentials

The functions included in this family of functions are:

aqs_credentials  aqs_sign_up

These functions are used to sign up with Data Mart and to storecredential information to use with RAQSAPI. The RAQSAPI::aqs_signupfunction takes one parameter:

The RAQSAPI::aqs_credentials function takes two parameters:

Data Mart API metadata functions

aqs_fields_by_service  aqs_isavailable  aqs_knownissues

These functions return the status of Data Mart API or metadataassociated with it.

The RAQSAPI::aqs_isavailable function takes no parameters and returnsa table which details the status of the AQS API.

The RAQSAPI::aqs_fields_by_service function takes one parameter,service, which is a R character object which represents the servicesprovided by the AQS API. For a list of available services seeAirQuality System (AQS) API - Services Overview

The RAQSAPI::aqs_knownissues function takes no parameters and Returnsa table of any known issues with system functionality or the data. Theseare usually issues that have been identified internally and will requiresome time to correct in Data Mart or the API. This function implements adirect API call to Data Mart and returns data directly from the API.Issues returned via this function do not include any issues from theRAQSAPI R package.

The RAQSAPI::aqs_revisionhistory function is used to query Data Martfor the change history to the API.

Data Mart API list functions

aqs_cbsas  aqs_classes  aqs_counties_by_state  aqs_mas  aqs_pqaos  aqs_sites_by_county  aqs_states

List functions return the API options or groupings that can be usedin conjunction with other API calls. By default each function in thiscategory returns results as a tibble. If return_header parameter is setto TRUE a AQSAPI_v2 object is returned instead.

RAQSAPI::aqs_cbsas returns a table of all available Core BasedStatistical Areas (cbsas) and their respective cbsa codes.

RAQSAPI::aqs_states takes no arguments and returns a table of theavailable states and their respective state FIPS codes.

RAQSAPI::aqs_sampledurations takes no arguments and returns a tableof the available sample duration code used to construct otherrequests.

RAQSAPI::aqs_classes takes no arguments and returns a table ofparameter classes (groups of parameters, i.e. “criteria” or “all”).

RAQSAPI::aqs_counties_by_state takes one parameter, stateFIPS, whichis a two digit state FIPS code for the state being requested representedas a R character object and returns a table of counties and theirrespective FIPS code for the state requested. Use RAQSAPI::aqs_states toreceive a table of valid state FIPS codes.

RAQSAPI::aqs_sites_by_county takes two parameters, stateFIPS, whichis a two digit state FIPS code for the state being requested andcounty_code which is a three digit county FIPS code for the county beingrequested, both stateFIPS and county_code should be encoded as a Rcharacter object This function returns a table of all air monitoringsites with the requested state and county FIPS code combination.

RAQSAPI::aqs_pqaos takes no parameters and returns anAQS_DATAMART_APIv2 S3 object containing a table of primary qualityassurance organizations (pqaos).

RAQSAPI::aqs_mas takes no parameters and returns anAQS_DATAMART_APIv2 S3 object containing a table of monitoring agencies(MA).

Data Mart aggregate functions

Information: AQS Data Mart API restrictsthe
maximum amount of monitoring data to one full year of data per
API call. These functions are able to return multiple years of databy
making repeated calls to the API. Each call to the Data Mart API willtake
time to complete. The more years of data being requested the longerRAQSAPI
will take to return the results.

These functions retrieve aggregated data from the Data Mart API andare grouped by how each function aggregates the data. There are 5different families of related aggregate functions. These families arearranged by how the Data Mart API groups the returned data, _by_site,_by_county, _by_state,by(_by_box) andby (_by_cbsa).Within each family of aggregated data functions there are functions thatcall on the 10 different services that the Data Mart API provides. AllAggregate functions return a tibble by default. If the return_Headerparameter is set to TRUE an AQS_DATAMART_APIv2 S3 object is returnedinstead.

  1. Monitors: Returns operational information aboutthe samplers (monitors) used to collect the data. Includes identifyinginformation, operational dates, operating organizations, etc. Functionsusing this service contain*monitors_by_* in the functionname.

  2. Sample Data: Returns sample data - the most finegrain data reported to EPA. Usually hourly, sometimes 5-minute, 12-hour,etc. This service is available in several geographic selections based ongeography: site, county, state, cbsa (core based statistical area, agrouping of counties), or by latitude/longitude bounding box. Functionsusing this service contain*sampledata_by_* in the functionname. All Sample Data functions accept two additional, optionalparameters; cbdate and cedate:

    • cbdate: a R date object which represents a “beginning date of lastchange” that indicates when the data was last updated. cbdate is used tofilter data based on the change date. Only data that changed on or afterthis date will be returned. This is an optional variable which defaultsto NA_Date_.
    • cedate: a R date object which represents an “end date of lastchange” that indicates when the data was last updated. cedate is used tofilter data based on the change date. Only data that changed on orbefore this date will be returned. This is an optional variable whichdefaults to NA_Date_.
    • duration: an optional R character string that represents theparameter duration code that limits returned data to a specific sampleduration. The default value of NA_character_ results in no filteringbased on duration code. Valid durations include actual sample durationsand not calculated durations such as 8 hour CO or\(O_3\) rolling averages, 3/6 day PM averagesor Pb 3 month rolling averages. Refer to [aqs_sampledurations()] for alist of all available duration codes.
  3. Daily Summary Data: Returns data summarized atthe daily level. All daily summaries are calculated on midnight tomidnight basis in local time. Variables returned include date, meanvalue, maximum value, etc. Functions using this service contain*dailysummary_by_* in the function name. All Daily Summary Datafunctions accept two additional parameters; cbdate and cedate:

    • cbdate: a R date object which represents a “beginning date of lastchange” that indicates when the data was last updated. cbdate is used tofilter data based on the change date. Only data that changed on or afterthis date will be returned. This is an optional variable which defaultsto NA_Date_.
    • cedate: a R date object which represents an “end date of lastchange” that indicates when the data was last updated. cedate is used tofilter data based on the change date. Only data that changed on orbefore this date will be returned. This is an optional variable whichdefaults to NA_Date_.
  4. Annual Summary Data: Returns data summarized atthe yearly level. Variables include mean value, maxima, percentiles,etc. Functions using this service contain*annualdata_by_* inthe function name. All Annual Summary Data functions accept twoadditional parameters; cbdate and cedate:

    • cbdate: a R date object which represents a “beginning date of lastchange” that indicates when the data was last updated. cbdate is used tofilter data based on the change date. Only data that changed on or afterthis date will be returned. This is an optional variable which defaultsto NA_Date_.
    • cedate: a R date object which represents an “end date of lastchange” that indicates when the data was last updated. cedate is used tofilter data based on the change date. Only data that changed on orbefore this date will be returned. This is an optional variable whichdefaults to NA_Date_.
  5. Quarterly Summary Data: Returns data summarizedat the quarterly level. Variables include mean value, maxima,percentiles, etc. Functions using this service contain*quarterlydata_by_* in the function name. All Annual SummaryData functions accept two additional parameters; cbdate and cedate:

    • cbdate: a R date object which represents a “beginning date of lastchange” that indicates when the data was last updated. cbdate is used tofilter data based on the change date. Only data that changed on or afterthis date will be returned. This is an optional variable which defaultsto NA_Date_.
    • cedate: a R date object which represents an “end date of lastchange” that indicates when the data was last updated. cedate is used tofilter data based on the change date. Only data that changed on orbefore this date will be returned. This is an optional variable whichdefaults to NA_Date_.
  6. Quality Assurance - Blanks Data: Qualityassurance data - blanks samples. Blanks are unexposed sample collectiondevices (e.g., filters) that are transported with the exposed sampledevices to assess if contamination is occurring during the transport orhandling of the samples. Functions using this service contain*qa_blanks_by_* in the function name.

  7. Quality Assurance - Collocated Assessments:Quality assurance data - collocated assessments. Collocated assessmentsare pairs of samples collected by different samplers at the same timeand place. (These are “operational” samplers, assessments withindependently calibrated samplers are called “audits”.). Functions usingthis service contain*qa_collocated_assessments_by_* in thefunction name.

  8. Quality Assurance - Flow Rate Verifications:Quality assurance data - flow rate verifications. Several times peryear, each PM monitor must have it’s (fixed) flow rate verified by anoperator taking a measurement of the flow rate. Functions using thisservice contain*qa_flowrateverification_by_* in the functionname.

  9. Quality Assurance - Flow Rate Audits: Qualityassurance data - flow rate audits. At least twice year, each PM monitormust have it’s flow rate measurement audited by an expert using adifferent method than is used for flow rate verifications. Functionsusing this service contain*qa_flowrateaudit_by_* in thefunction name.

  10. Quality Assurance - One Point Quality Control RawData: Quality assurance data - one point quality control checkraw data. At least every two weeks, certain gaseous monitors must bechallenged with a known concentration to determine monitor performance.Functions using this service contain*qa_one_point_qc_by_* inthe function name.

  11. Quality Assurance - pep Audits: Qualityassurance data - performance evaluation program (pep) audits. pep auditsare independent assessments used to estimate total measurement systembias with a primary quality assurance organization. Functions using thisservice contain*qa_pep_audit_by_* in the functionname.

  12. Transaction Sample - AQS Submission data in transactionformat (RD): Transaction sample data - The raw transactionsample data uploaded to AQS by the agency responsible for datasubmissions in RD format. Functions using this service contain*transactionsample_by_* in the function name. Transactionsample data is only available aggregated by site, county, state ormonitoring agency.

  13. Quality Assurance - Annual PerformanceEvaluations: Quality assurance data - Annual performanceevaluations. A performance evaluation must be conducted on each primarymonitor once per year. The percent differences between known andmeasured concentrations at several levels are used to assess the qualityof the monitoring data. Functions using this service contain*aqs_qa_annualperformanceeval_by_* in the function name. Annualperformance in transaction format are only available aggregated by site,county, state, monitoring agency, and primary quality assuranceorganization. Annual performance evaluations are only availableaggregated by site, county, state, monitoring agency, and primaryquality assurance organization.

  14. Quality Assurance - Annual performance Evaluations intransaction
    format (RD): Quality assurance data - The rawtransaction annual performance evaluations data in RD format. Functionsusing this service contain*aqs_qa_annualperformanceevaltransaction_by_* in the functionname. Annual performance evaluations in transaction format are onlyavailable aggregated by site, county, state, monitoring agency, andprimary quality assurance organization.

Data Mart aggregate functions _by_site

aqs_annualsummary_by_site  aqs_dailysummary_by_site  aqs_monitors_by_site  aqs_qa_annualperformanceeval_by_site  aqs_qa_annualperformanceevaltransaction_by_site  aqs_qa_blanks_by_site  aqs_qa_collocated_assessments_by_site  aqs_qa_flowrateaudit_by_site  aqs_qa_flowrateverification_by_site  aqs_qa_one_point_qc_by_site  aqs_qa_pep_audit_by_site  aqs_quarterlysummary_by_site  aqs_sampledata_by_site  aqs_transactionsample_by_site

functions in this family of functions aggregate data at the sitelevel. All *_by_site functions accept the following variables:

  • parameter:
  • bdate:
  • edate:
  • stateFIPS:
  • countycode:
  • sitenum:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* functions and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* functions and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

Data Mart aggregate functions _by_county

aqs_annualsummary_by_county  aqs_dailysummary_by_county  aqs_monitors_by_county  aqs_qa_annualperformanceeeval_by_county  aqs_qa_annualperformanceevaltransaction_by_county  aqs_qa_blanks_by_county  aqs_qa_collocated_assessments_by_county  aqs_qa_flowrateaudit_by_county  aqs_qa_flowrateverification_by_county  aqs_qa_one_point_qc_by_county  aqs_qa_pep_audit_by_county  aqs_quarterlysummary_by_county  aqs_sampledata_by_county  aqs_sites_by_county  aqs_transactionsample_by_county

functions in this family of functions aggregate data at the countylevel. All functions accept the following variables:

  • parameter:
  • bdate:
  • edate:
  • stateFIPS:
  • countycode:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

Data Mart aggregate functions _by_state

aqs_annualsummary_by_state  aqs_counties_by_state  aqs_dailysummary_by_state  aqs_monitors_by_state  aqs_qa_annualperformanceeval_by_state  aqs_qa_annualperformanceevaltransaction_by_state  aqs_qa_blanks_by_state  aqs_qa_collocated_assessments_by_state  aqs_qa_flowrateaudit_by_state  aqs_qa_flowrateverification_by_state  aqs_qa_one_point_qc_by_state  aqs_qa_pep_audit_by_state  aqs_quarterlysummary_by_state  aqs_sampledata_by_state  aqs_transactionsample_by_state

functions in this family of functions aggregate data at the statelevel. All functions accept the following variables:

  • parameter:
  • bdate:
  • edate:
  • stateFIPS:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* functions and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

Data Mart aggregate functions by Monitoring agency (MA)

aqs_qa_annualperformanceeval_by_MA  aqs_qa_annualperformanceevaltransaction_by_MA  aqs_qa_blanks_by_MA  aqs_qa_collocated_assessments_by_MA  aqs_qa_flowrateaudit_by_MA  aqs_qa_flowrateverification_by_MA  aqs_qa_one_point_qc_by_MA  aqs_qa_pep_audit_by_MA  aqs_transactionsample_by_MA

functions in this family of functions aggregate data at theMonitoring Agency (MA) level. All functions accept the followingvariables:

  • parameter:
  • bdate:
  • edate:
  • MA_code:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledataby*,*dailysummaryby*,*annualdataby* and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledataby*,*dailysummaryby*,*annualdataby* and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

Data Mart aggregate functions by Core Based Statistical Area(cbsa)

aqs_annualsummary_by_cbsa  aqs_dailysummary_by_cbsa  aqs_monitors_by_cbsa  aqs_sampledata_by_cbsa

functions in this family of functions aggregate data at the CoreBased Statistical Area (cbsa, as defined by the US Census Bureau) level.All functions accept the following variables:

  • parameter:
  • bdate:
  • edate:
  • cbsa_code:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

Data Mart aggregate functions by Primary Quality AssuranceOrganization (pqao)

aqs_qa_annualperformanceeval_by_pqao  aqs_qa_annualperformanceevaltransaction_by_pqao  aqs_qa_blanks_by_pqao  aqs_qa_collocated_assessments_by_pqao  aqs_qa_flowrateaudit_by_pqao  aqs_qa_flowrateverification_by_pqao  aqs_qa_one_point_qc_by_pqao  aqs_qa_pep_audit_by_pqao  aqs_quarterlysummary_by_pqao

functions in this family of functions aggregate data at the PrimaryQuality Assurance Organization (pqao) level. All functions accept thefollowing variables:

  • parameter:
  • bdate:
  • edate:
  • pqao_code:
  • return_header (optional): set to FALSE by default.

Data Mart aggregate functions by latitude/longitude bounding box(_by_box)

aqs_annualsummary_by_box  aqs_dailysummary_by_box  aqs_monitors_by_box  aqs_quarterlysummary_by_box  aqs_sampledata_by_box

Functions in this family of functions aggregate data by alatitude/longitude bounding box (_by_box) level. All functions acceptthe following variables:

  • parameter:
  • bdate:
  • edate:
  • minlat:
  • minlon:
  • maxlon:
  • maxlat:
  • cbdate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • cedate (optional): (This parameter is only used in conjunction with*sampledata_by_*,*dailysummary_by_*,*annualdata_by_* and*quarterlysummary_by_*functions).
  • return_header (optional): set to FALSE by default.
  • duration (optional): (This parameter is only used in conjunctionwith*sampledata_by_* functions).

RAQSAPI Miscellaneous functions

aqs_removeheader

These are miscellaneous functions exported by RAQSAPI.

RAQSAPI::aqs_removeheader is the function that the RAQSAPI libraryuses internally to coerce an AQS_DATAMART_APIv2 S3 object into a tibble.This is useful if the user saves the output from another RAQSAPIfunction with return_header = TRUE set but later decides that they wantjust a simple tibble object. This function takes only one variable:

  • AQSobject:

Troubleshooting

Parameters must be supplied exactly as they are specified, forexample the stateFIPS for Alabama is “01”, entering a value of “1” forthe stateFIPS may lead to unexpected results. Do not omit leading zerosin parameters that expect them.

In Functions that have the return_header=TRUE option set the returnedobject is an AQSAPI_v2 object, this is a 2 item list where the firstobject is a tibble with the label $Header, the second, a tibble with thelabel $Data. sampledata functions are limited by the API to one calendaryear of data per API call so if the user requests multiple years of datathe sampledata call will return multiple AQSAPI_v2 objects, one for eachcall to the API. The returned result is a list of AQSAPI_v2 objects. InR to access the data in each item in the list the user will need to usethe “double bracket operator” (“[[”, ”]]”) not the single bracketoperator (“[”, ”]”).

pyaqsapi - a port of RAQSAPI to the python 3 programmingenvironment

For users that feel more comfortable working within a python 3environment,pyaqsapi4, a port of RAQSAPI to the python 3language has been released. Both projects aim to maintain feature paritywith the other and there are no inherent advantages to using eitherproject over the other, except for the ability of working within theprogramming language environment of choice. The API of both packages arevery structured similarly, both packages export the same data, use thesame credentials and data source to retrieve data.

Acknowledgements

RAQSAPI was included in the Rblogger’s March 2021: “Top 40”NewCRAN Packages.

The RAQSAPI package borrows upon functions and code provided bysources not mentioned in the DESCRIPTION file. Here we attempt toacknowledge those sources with them RAQSAPI would not be possible.

References

(1)
AQSdata mart welcomehttps://aqs.epa.gov/aqsweb/documents/data_mart_welcome.html.
(2)
Müller, K.; Wickham, H.Tibble: Simple DataFrames; 2021.
(3)
AboutAQS datahttps://aqs.epa.gov/aqsweb/documents/about_aqs_data.html.
(4)
Mccrowey, C.A Python 3 Package to RetrieveAmbient Air Monitoring Data from the United States EnvironmentalProtection Agency’s (US EPA) Air Quality System (AQS) Data Mart API V2Interface, 2022.
(5)
Hogervorst, R. M.Badgecreatr:Create Badges for ’Travis’, ’Repostatus’ ’Codecov.io’ Etc in GithubReadme; 2019.
(6)
Wickham, H.; Bryan, J.; Barrett, M.Usethis: AutomatePackage and Project Setup; 2021.
(7)
Hester, J.; Angly, F.; Hyde, R.Lintr: A ’Linter’ for rCode; 2020.
(8)
Team, R. C.R: A Language and Environment forStatistical Computing; R Foundation for Statistical Computing:Vienna, Austria, 2019.
(9)
Csárdi, G.; Hester, J.; Wickham, H.; Chang, W.;Morgan, M.; Tenenbaum, D.Remotes: R PackageInstallation from Remote Repositories, Including ’GitHub’;2021.
(10)
Druskat, S.; Spaaks, J. H.; Chue Hong, N.;Haines, R.; Baker, J.; Bliven, S.; Willighagen, E.; Pérez-Suárez, D.;Konovalov, A. CitationFileFormat, 2021.https://doi.org/10.5281/zenodo.5171937.
(11)
R-Lib/Urlchecker onGithub.

  1. RAQSAPI’s rate limit does not guarantee that the userwill not go over the rate limit and does not guarantee that API calls donot overload the AQS Data Mart system, each user should monitor theirrequests independently.↩︎

  2. Use “?aqs_sign_up” after the RAQSAPI library has beenloaded to see the full usage description of the aqs_sign_up function.↩︎

  3. Use “?aqs_credentials” after the RAQSAPI library hasbeen loaded to see the full usage description of the aqs_credentialsfunction.↩︎

  4. [RKeyring package]https://cran.r-project.org/package=keyring)↩︎

  5. See (https://aqs.epa.gov/aqsweb/documents/data_api.html) forfull details of the Data Mart API↩︎


[8]ページ先頭

©2009-2025 Movatter.jp