epa_aqs_createLocalArchive: Create a 'data' dataframe with required data

View source: R/epa_aqs_createLocalArchive.R

epa_aqs_createLocalArchiveR Documentation

Create a 'data' dataframe with required data

Description

Create a local archive of EPA AQS transofrmed into data appropriate for use with the MazamaTimeSeries package.

The data model is that data are stored in a tibble named data with an initial datetime column and monitor-specific data in columns identified with a deviceDeploymentID that matches one found in the incoming meta table. Both data and meta will be saved as '.rda', '.csv' and '.csv.gz' files for maximum portability to other languages like python, javascript or even to desktop spreadsheet software.

The archive structure underneath archiveBaseDir will be:

<archiveBaseDir>/EPA_AQS/<parameterCode>/<year>/

Files will be named as:

epa_aqs_<parameterCode>_<year>_meta.[rda|csv|csv.gz]
epa_aqs_<parameterCode>_<year>_data.[rda|csv|csv.gz]

Usage

epa_aqs_createLocalArchive(
  sites_locationTbl = NULL,
  parameterCode = NULL,
  years = NULL,
  archiveBaseDir = NULL,
  downloadDir = NULL,
  quiet = FALSE
)

Arguments

sites_locationTbl

EPA AQS "known locations" table for parameterCode monitors.

parameterCode

EPA "Parameter Code".

years

Vector of years for which to transform data.

archiveBaseDir

Path under which the directory structure will be created.

downloadDir

Directory in which to save downloaded EPA .zip files. If NULL, a temp directory is used.

quiet

Logical passed on to utils::download.file().

Value

Returns 0 on success.

Note

Depending on your internet connection speeds, downloading files from the EPA site can take several minutes per file. If you see warning messages that you have timed out, please download files manually before running this function. This function will then discover the downloaded files in the downloadDir.


pnwairfire/AirMonitorIngest documentation built on Feb. 18, 2025, 7:50 p.m.