epa_aqs_downloadHourlyData: Download hourly EPA air quality data

View source: R/epa_aqs_downloadHourlyData.R

epa_aqs_downloadHourlyDataR Documentation

Download hourly EPA air quality data

Description

Download hourly air quality data from the US EPA and save it to a directory.

EPA parameter codes and (start year) include:

44201

– Ozone (1980)

42401

– SO2 (1980)

42101

– CO (1980)

42602

– NO2 (1980)

88101

– PM2.5 FRM/FEM (2008)

88502

– PM2.5 non FRM/FEM (1998)

81102

– PM10 (1988)

SPEC

– PM2.5 Speciation(2001)

PM10SPEC

– PM10 Speciation (1988)

WIND

– Winds (1980)

TEMP

– Temperature (1980)

PRESS

– Barometric Pressure (1980)

RH_DP

– RH and Dewpoint (1980)

HAPS

– HAPs (1993)

VOCS

– VOCs (1980)

NONOxNOy

– Nitrous Oxides (1980)

Usage

epa_aqs_downloadHourlyData(
  parameterCode = "88101",
  year = NULL,
  baseUrl = "https://aqs.epa.gov/aqsweb/airdata/",
  downloadDir = tempdir(),
  quiet = TRUE
)

Arguments

parameterCode

Character pollutant code.

year

Ingeter year.

baseUrl

Character base URL for the EPA AQS archive.

downloadDir

Directory where .zip file will be saved.

quiet

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

Value

Filepath of the downloaded zip file.

Note

Unzipped CSV files are almost 100X larger than the compressed .zip files.

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. Functions that process these files will then discover the downloaded files in the downloadDir.

References

EPA AirData Pre-Generated Data Files

Examples

## Not run: 
library(AirMonitorIngest)

# Create a directory specifically for EPA data
dir.create("~/Data/EPA", recursive = TRUE)

# Set logging level so messages and errors will appear in the console
MazamaCoreUtils::initializeLogging(logDir = "~/Data/EPA/")
logger.setLevel(TRACE)

# Save the download in ~/Data/EPA
zipFile <-
  epa_aqs_downloadHourlyData(
    parameterCode = "88101",
    year = 2008,
    downloadDir = "~/Data/EPA/",
    quiet = FALSE
  )

# Uncompress and parse into a tibble
tbl <- epa_aqs_parseHourlyData(zipFile)

## End(Not run)

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