Introduction to echor

Michael Schramm

2018-09-10

echor introduction

echor is an R package to search and download data from the US Environmental Protection Agency (EPA) Environmental Compliance and History Online (ECHO). echor uses the ECHO API to download data directly to the R as dataframes or simple features. ECHO provides information about facilities permitted to emitted air pollutants or discharge into water bodies. ECHO also provides data reported by permitted facilites as volume or concentration of pollutants during reporting time periods (typically anually for air emissions and monthly or quarterly for water discharges).

ECHO provides data for:

echor currently provides functions to retrieve information about permitted air dischargers, water dischargers, and public drinking water supply systems. It also provides functions to download discharge reports for permitted air and water dischargers. echor does not currently provide functionality to retrieve RCRA data.

See https://echo.epa.gov/tools/web-services for information about ECHO web services and API functions.

Getting started

This vignette documents a few key functions to get started.

There are three types of functions:

Metadata

Retrieve metadata from ECHO to narrow the specify data returned or lookup parameter codes.

Query Facilities

Search and return facility information based on lookup parameters.

Reports

Search and return discharge and emissions reports for specified facilities.

Sample workflows

Air

Suppose we want to find facilities permitted under the Clean Air Act requirements.

Step 1 - Identify the information we need returned from the query:

The dataframe includes ColumnID, which can be included as an argument that specifies what information you want returned: qcolumns = "1,2,3,22,23"

Step 2 - Create the query. The ECHO API provides numerous arguments to search by that are not documented in this package. I reccomend exploring the documentation here: https://echo.epa.gov/tools/web-services/facility-search-air#!/Facilities/get_air_rest_services_get_facility_info. In this example, we will search by a geographic bounding box and specfiy the returned information with the qcolumns argument. Each argument should be passeed to ECHO as echoAirGetFacilityInfo(parameter = "value"). echor will URL encode strings automatically. Please note that any date argument needs to be entered as “mm/dd/yyyy”.

AIRName SourceID AIRStreet FacLat FacLong
AGGIE CLEANERS 06000000480416E020 111 COLLEGE MAIN 30.61869 -96.34588
ALL SEASONS 1 HR CLEANERS 06000000480416E015 2501 TEXAS AVENUE SOUTH #D100 30.60704 -96.30875
BLUEBONNET PAVING TX0000004877700147 HWY. 60, WEST OF 30.61337 -96.32098
BRYAN CERAMICS PLANT TX0000004804100027 1500 INDEPENDENCE AVE 30.63760 -96.36235
BRYAN CLEANERS & LAUNDRY 06000000480416E012 1803 HOLLEMAN DRIVE 30.61225 -96.31750
CITY OF BRYAN TX0000004804100026 1.5 MI W OF @FM 1687 & FM 2818 30.63760 -96.36235

Some example arguments are listed below:

p_fn  string  Facility Name Filter.
              One or more case-insesitive facility names.
              Provide multiple values as comma-delimited list
              ex:
              p_fn = "Aggie Cleaners, City of Bryan, TEXAS A&M UNIVERSITY COLLEGE STATION CAMPUS"
              
p_sa  string  Facility Street Address
              ex:
              p_sa = "WELLBORN ROAD & UNIVERSITY DR"
              
p_ct  string  Facility City
              Provide a single case-insensitive city name
              ex:
              p_ct = "College Station"
              
p_co  string  Facility County
              Provide a single county name, in combination with a state value
              provided through p_st
              ex:
              p_co = "Brazos", p_st = "Texas"
              
p_fips  string  FIPS Code
                Single 5-character Federal Information Processing Standards (FIPS) 
                state+county value
                
p_st  string  Facility State or State Equivalent Filter
              Provide one or more USPS postal abbreviations
              ex:
              p_st = "TX, NC"
              
p_zip string  Facility 5-Digit Zip Code
              Provide one or more 5-digit postal zip codes
              ex:
              p_zip = "77843, 77845"
              
xmin  string  Minimum longitude value in decimal degrees

ymin  string  Minimum latitude value in decimal degrees

xmax  string  Maximum longitude value in decimal degrees

ymax  string  Maximum latitude value in decimal degrees

Step 3 - Download the emission inventory report for a permitted facility:

Name SourceID Street City State Zip County Region Latitude Longitude Pollutant UnitsOfMeasure Program Year Discharge
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 Carbon dioxide Pounds CAMD 2008 5.90014e+09
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 Nitrogen oxides Pounds CAMD 2008 9.95600e+06
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 1,2-Dichloroethane Pounds NEI 2008 4.79500e+01
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 Acetophenone Pounds NEI 2008 1.79800e+01
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 Anthracene Pounds NEI 2008 2.50000e-01
CP&L - SUTTON PLANT 110000350174 801 SUTTON STEAM PLANT ROAD WILMINGTON NC 28401 NEW HANOVER 04 34.28332 -77.98523 Dimethyl sulfate Pounds NEI 2008 6.31900e+01

There are only two valid arguments for echoGetCAAPR.

p_id  string  EPA Facility Registry Service's REGISTRY_ID.

p_units string  Units of measurement. Defaults is 'lbs'.
                Enter "TPWE" for toxic weighted pounds equivalents.

Water facility and discharge searches

Find facilites with NPDES permits to discharge wastewater:

CWPName SourceID CWPStreet CWPCity CWPState CWPStateDistrict CWPZip MasterExternalPermitNmbr RegistryID CWPCounty CWPEPARegion FacDerivedHuc FacLat FacLong CWPTotalDesignFlowNmbr CWPActualAverageFlowNmbr ReceivingMs4Name AssociatedPollutant MsgpPermitType CWPPermitStatusDesc CWPPermitTypeDesc CWPIssueDate CWPEffectiveDate CWPExpirationDate CWPSNCStatusDate CWPStateWaterBodyCode
AGGIE ACRES WWTP TX0132187 800 FT SE OF N DOWLING RD APPROX 600 FT SW OF WALN COLLEGE STATION TX 77845 110064633829 Brazos 06 30.55565 -96.29110 NA NA Not Needed NPDES Individual Permit NA NA NA 2018-03-31
AGRIVEST SWINE FEEDLOT TX0121240 SWISHER COUNTY BRYAN TX 00000 110039193271 Swisher 06 30.66658 -96.36552 NA NA Terminated NPDES Individual Permit 2000-01-14 2000-01-14 2004-07-27 2018-03-31
ATKINS STREET POWER STATION TX0027952 601 ATKINS STREET BRYAN TX 77801 110001866623 Brazos 06 12070103 30.64816 -96.37165 NA 0.385 Terminated NPDES Individual Permit 2014-08-28 2014-09-01 2019-05-01 2018-03-31 120701030340
ATOFINA CHEMICALS, INC. TX0108863 SW OF THE MO PACIFIC RR & BRYAN TX 77801 110000464293 Brazos 06 12070103 30.65792 -96.37303 NA NA Expired NPDES Individual Permit 2009-06-30 2009-07-01 2013-05-01 2018-03-31 12070101
BARTLETT 1 TX0120421 SWISHER COUNTY AMARILLO TX 00000 110039193271 Swisher 06 30.66658 -96.36552 NA NA Terminated NPDES Individual Permit 2000-01-14 2000-01-14 2004-07-27 2018-03-31
BOSSIER PARISH RESOURCE CENTER LAG830191 3228 BARKDALE BLVD BENTON LA 71111 LAG830000 110016696832 Bossier 06 12070103 30.61602 -96.28182 NA NA Terminated General Permit Covered Facility 2012-12-15 2012-12-15 2017-12-14 2018-03-31 11140204

Again, there are a ton of possible arguments to query ECHO with. All arguments are described here: https://echo.epa.gov/tools/web-services/facility-search-water#!/Facility_Information/get_cwa_rest_services_get_facility_info

Commonly used arguments are provided below:

p_fn  string  Facility Name Filter.
              One or more case-insesitive facility names.
              Provide multiple values as comma-delimited list
              ex:
              p_fn = "Aggie Cleaners, City of Bryan, TEXAS A&M UNIVERSITY COLLEGE STATION CAMPUS"
              
p_sa  string  Facility Street Address
              ex:
              p_sa = "WELLBORN ROAD & UNIVERSITY DR"
              
p_ct  string  Facility City
              Provide a single case-insensitive city name
              ex:
              p_ct = "College Station"
              
p_co  string  Facility County
              Provide a single county name, in combination with a state value
              provided through p_st
              ex:
              p_co = "Brazos", p_st = "Texas"
              
p_fips  string  FIPS Code
                Single 5-character Federal Information Processing Standards (FIPS) 
                state+county value
                
p_st  string  Facility State or State Equivalent Filter
              Provide one or more USPS postal abbreviations
              ex:
              p_st = "TX, NC"
              
p_zip string  Facility 5-Digit Zip Code
              Provide one or more 5-digit postal zip codes
              ex:
              p_zip = "77843, 77845"
              
xmin  string  Minimum longitude value in decimal degrees

ymin  string  Minimum latitude value in decimal degrees

xmax  string  Maximum longitude value in decimal degrees

ymax  string  Maximum latitude value in decimal degrees

p_huc string  2-,4,6-,or 8-digit watershed code.
              May contain comma-seperated values
              

Download discharge monitoring reports from ECHO from specified facilities:

Name Outfall ID RegistryID Location City State Zip Status LimitBeginDate LimitEndDate LimitValueNmbr LimitUnitCode LimitUnitDesc StdUnitCode StdUnitDesc LimitValueStdUnit StatisticalBaseCode StatisticalBaseDesc StatisticalBaseTypeCode StatisticalBaseTypeDesc DMREventId MonitoringPeriodEndDate DMRFormValueId ValueTypeCode ValueTypeDesc DMRValueId DMRValueNmbr DMRUnitCode DMRUnitDesc DMRValueStdUnits DMRQualifierCode ValueReceivedDate DaysLate NODICode NODEDesc ExceedancePct NPDESViolations
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 0.131 03 MGD MGD MGD NA DB DAILY AV AVG Average 3403423151 16678 3442281023 Q1 Quantity1 3612155723 0.0492 03 MGD 0.0492 NA 16695 NA NA NA NA NA
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 NA 03 MGD MGD MGD NA DD DAILY MX MAX Maximum 3403423151 16678 3442281032 Q2 Quantity2 3612155724 0.0534 03 MGD 0.0534 NA 16695 NA NA NA NA NA
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 0.131 03 MGD MGD MGD NA DB DAILY AV AVG Average 3403423173 16708 3442281323 Q1 Quantity1 3613394763 0.0512 03 MGD 0.0512 NA 16728 NA NA NA NA NA
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 NA 03 MGD MGD MGD NA DD DAILY MX MAX Maximum 3403423173 16708 3442281328 Q2 Quantity2 3613394764 0.0710 03 MGD 0.0710 NA 16728 NA NA NA NA NA
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 0.131 03 MGD MGD MGD NA DB DAILY AV AVG Average 3403423185 16739 3442281496 Q1 Quantity1 3614856996 0.0480 03 MGD 0.0480 NA 16759 NA NA NA NA NA
SKIDMORE WSC WWTP 001 TX0119407 110009771693 1000’ N OF THE END OF BLACK RANCH RD AND APPROX SKIDMORE TX 78387 78387 16648 18322 NA 03 MGD MGD MGD NA DD DAILY MX MAX Maximum 3403423185 16739 3442281524 Q2 Quantity2 3614856997 0.0613 03 MGD 0.0613 NA 16759 NA NA NA NA NA

This function only retrieves from a single facility per call. The following arguments are available from ECHO:

p_id  string  EPA Facility Registry Service's REGISTRY_ID.

outfall string  Three-character code identifying the point of discharge.

parameter_code  string  Five-digit numeric code identifying the parameter.

start_date  string  Start date of interest. Must be entered as "mm/dd/yyyy"

end_date  string  End date of interest. Must be entered as "mm/dd/yyyy"

Parameters codes can be searched using echoWaterGetParams.

Available arguments include:

term string partial or complete search phrase or word

code  string  partial or complete code value

You can only enter either term or code arguments.

Spatial data

echor can also return spatial data frames known as simple features (https://r-spatial.github.io/sf/), to facilitate creation of maps. Both echoAirGetFacilityInfo and echoWaterGetFacilityInfo include arguments to return simple feature dataframes.

Using sf, ggmap, and the current development version of ggplot2 (devtools::install_github("tidyverse/ggplot2")), we can quickly create a map of downloaded data.