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 air emissions and wastewater discharge data. Later releases will include functions to download drinking water supply and hazardous waste info from ECHO.
See https://echo.epa.gov/tools/web-services for information about ECHO web services and API functions.
This vignette docuemnts a few key functions to get started.
The two main functions used to retrieve air emissions permit and facility data are: echoAirGetFacilityInfo
and echoGetCAAPR
. echoAirGetFacilityInfo
returns a dataframe or simple features geospatial dataframe with information about permittee that match the query. echoGetCAAPR
returns a dataframe with the emissions inventory report of the queried facility.
The two main functions used to retrieve data about facilities with permits to discharge into water bodies are echoWaterGetFacilityInfo
and echoGetEffluent
. echoWaterGetFacilityInfo
returns a dataframe or simple features geospatial dataframe with information about permitees that match the query. echoGetEffluent
returns a dataframe with reported discharges from the queried facilities.
Find facilities with a permit to emit air pollutants under the Clean Air Act:
library(echor)
## Retrieve information about facilities within a geographic location
df <- echoAirGetFacilityInfo(output = "df",
xmin = '-96.387509',
ymin = '30.583572',
xmax = '-96.281422',
ymax = '30.640008')
ObjectId | AIRName | SourceID | AIRStreet | AIRCity | AIRState | LocalControlRegionCode | AIRZip | RegistryID | AIRCounty | AIREPARegion | FacFederalAgencyCode | FacFederalAgencyName | FacDerivedHuc | FacFIPSCode | FacIndianCntryFlg | AIRIndianCntryFlg | FacIndianSpatialFlg | FacDerivedTRIbes | FacUsMexBorderFlg | FacSICCodes | AIRNAICS | FacLat | FacLong | AIRPrograms | AIRMacts | AIRStatus | AIRUniverse | FacDerivedWBD | FacDerivedWBDName | ChesapeakeBayFlag | AIRIDs | CWAIDs | RCRAIDs | RmpIDs | SDWAIDs | TRIIDs | GHGIDs | EisIDs | CamdIDs | AIRCurrComplStatus | AIRCurrHpv | AIRMnthsInHpv | AIRQtrsInHpv | AIRQtrsWithViol | AIRPollRecentViol | AIRRecentViolCnt | AIRLastViolDate | AIREvalCnt | AIRDaysLastEval | AIRLastEvalDate | AIRLastEvalDateEPA | AIRLastEvalDateState | LastDatePce | LastDatePceEPA | LastDatePceSta | AIRLastStckTestDate | AIRLastStckTestResults | FacNaaFlag | FacTRIReporter | FacTRIAIRReleases |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | AGGIE CLEANERS | 06000000480416E020 | 111 COLLEGE MAIN | COLLEGE STATION | TX | NA | 778401221 | 110001873786 | Brazos | 06 | NA | NA | 12070101 | 48041 | N | N | N | NA | N | 7216 | 999999 | 30.61869 | -96.34588 | MACT | M | Operating | Minor Emissions | 120701030702 | Bee Creek-Carters Creek | NA | 06000000480416E020 | NA | NA | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 0 | 7725 | 02/19/1997 | 02/19/1997 | NA | NA | NA | NA | NA | NA | NA | NA | NA |
2 | ALL SEASONS 1 HR CLEANERS | 06000000480416E015 | 2501 TEXAS AVENUE SOUTH #D100 | COLLEGE STATION | TX | NA | 77840 | 110001873731 | Brazos | 06 | NA | NA | 12070103 | 48041 | N | N | N | NA | N | 7216 | 999999 | 30.60704 | -96.30875 | MACT | M | Operating | Minor Emissions | 120701030702 | Bee Creek-Carters Creek | NA | 06000000480416E015 | NA | TXD981611270 | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 0 | 7725 | 02/19/1997 | 02/19/1997 | NA | NA | NA | NA | NA | NA | NA | NA | NA |
3 | BLUEBONNET PAVING | TX0000004877700147 | HWY. 60, WEST OF | COLLEGE STATION | TX | NA | 77840 | 110007194044 | Brazos | 06 | NA | NA | NA | 48777 | N | N | N | NA | NA | 2951 | 999999 | 30.613371 | -96.320977 | NSPS | NA | Operating | Minor Emissions | NA | NA | NA | TX0000004877700147 | NA | NA | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA |
4 | BRYAN CERAMICS PLANT | TX0000004804100027 | 1500 INDEPENDENCE AVE | BRYAN | TX | NA | 77803 | 110007200830 | Brazos | 06 | NA | NA | NA | 48041 | N | N | N | NA | NA | NA | 325188 | 30.637595 | -96.362352 | SIP, TVP | NA | Operating | Major Emissions | NA | NA | NA | TX0000004804100027 | NA | NA | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 2 | 481 | 12/20/2016 | NA | 12/20/2016 | 01/17/2013 | NA | 01/17/2013 | 03/12/2012 | Pass | NA | NA | NA |
5 | BRYAN CLEANERS & LAUNDRY | 06000000480416E012 | 1803 HOLLEMAN DRIVE | COLLEGE STATION | TX | NA | 77840 | 110001873713 | Brazos | 06 | NA | NA | 12070103 | 48041 | N | N | N | NA | N | 7216 | 999999 | 30.61225 | -96.317503 | MACT | M | Operating | Minor Emissions | 120701030702 | Bee Creek-Carters Creek | NA | 06000000480416E012 | NA | NA | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 0 | 7725 | 02/19/1997 | 02/19/1997 | NA | NA | NA | NA | NA | NA | NA | NA | NA |
6 | CITY OF BRYAN | TX0000004804100026 | 1.5 MI W OF @FM 1687 & FM 2818 | BRYAN | TX | NA | 77801 | 110007194142 | Brazos | 06 | NA | NA | NA | 48041 | N | N | N | NA | NA | 4953 | 999999 | 30.637595 | -96.362352 | SIP | NA | Operating | Minor Emissions | NA | NA | NA | TX0000004804100026 | NA | NA | NA | NA | NA | NA | NA | NA | No Viol | No | 0 | 0 | 0 | NA | 0 | NA | 0 | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA |
There are over 100 arguments that can be passed to echoAirGetFacilityInfo()
to filter permitted facilites. They are documented here: https://echo.epa.gov/tools/web-services/facility-search-air#!/Facilities/get_air_rest_services_get_facility_info. Each argument should be passeed to ECHO as echoAirGetFaclityInfo(parameter = "value")
. echor
will URL encode strings automatically. Please note that any date argument needs to be entered as “mm/dd/yyyy”.
The most useful 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
Download emissions inventory report data:
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 | 2,4-Dinitrotoluene | Pounds | NEI | 2007 | NA |
CP&L - SUTTON PLANT | 110000350174 | 801 SUTTON STEAM PLANT ROAD | WILMINGTON | NC | 28401 | NEW HANOVER | 04 | 34.28332 | -77.98523 | 2-Chloroacetophenone | Pounds | NEI | 2007 | NA |
CP&L - SUTTON PLANT | 110000350174 | 801 SUTTON STEAM PLANT ROAD | WILMINGTON | NC | 28401 | NEW HANOVER | 04 | 34.28332 | -77.98523 | Acenaphthene | Pounds | NEI | 2007 | NA |
CP&L - SUTTON PLANT | 110000350174 | 801 SUTTON STEAM PLANT ROAD | WILMINGTON | NC | 28401 | NEW HANOVER | 04 | 34.28332 | -77.98523 | Acetaldehyde | Pounds | NEI | 2007 | NA |
CP&L - SUTTON PLANT | 110000350174 | 801 SUTTON STEAM PLANT ROAD | WILMINGTON | NC | 28401 | NEW HANOVER | 04 | 34.28332 | -77.98523 | Acetophenone | Pounds | NEI | 2007 | NA |
CP&L - SUTTON PLANT | 110000350174 | 801 SUTTON STEAM PLANT ROAD | WILMINGTON | NC | 28401 | NEW HANOVER | 04 | 34.28332 | -77.98523 | Allyl chloride | Pounds | NEI | 2007 | NA |
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.
Find facilites with NPDES permits to discharge wastewater:
df <- echoWaterGetFacilityInfo(xmin = '-96.407563', ymin = '30.554395',
xmax = '-96.25947', ymax = '30.751984',
output = 'df')
ObjectId | CWPName | SourceID | CWPStreet | CWPCity | CWPState | CWPStateDistrict | CWPZip | MasterExternalPermitNmbr | CWPCounty | CWPEPARegion | FacFederalAgencyCode | FacLong | CWPFacilityTypeIndicator | ReceivingMs4Name | SpeciesCriticalHabitalFlag | ExposedActivity | AssociatedPollutant | ControlMeasure | ControlMeasureSchedule | EjscreenFlagUs | Over80CountUs | PctilePctpre1960Us | PctileProximityRmpUs | PctileProximityTsdfUs |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | AGGIE ACRES WWTP | TX0132187 | 800 FT SE OF N DOWLING RD APPROX 600 FT SW OF WALN | COLLEGE STATION | TX | NA | 77845 | NA | Brazos | 06 | NA | -96.291099 | NON-POTW | NA | NA | NA | NA | NA | NA | N | NA | NA | NA | NA |
2 | AGRIVEST SWINE FEEDLOT | TX0121240 | SWISHER COUNTY | BRYAN | TX | NA | 00000 | NA | Swisher | 06 | NA | -96.36552 | NON-POTW | NA | NA | NA | NA | NA | NA | N | NA | NA | NA | NA |
3 | ATKINS STREET POWER STATION | TX0027952 | 601 ATKINS STREET | BRYAN | TX | NA | 77801 | NA | Brazos | 06 | NA | -96.37165 | NON-POTW | NA | NA | NA | NA | NA | NA | Y | 4 | 82.2 | 82.4 | 70.4 |
4 | ATOFINA CHEMICALS, INC. | TX0108863 | SW OF THE MO PACIFIC RR & | BRYAN | TX | NA | 77801 | NA | Brazos | 06 | NA | -96.37303 | NON-POTW | NA | NA | NA | NA | NA | NA | Y | 4 | 82.2 | 82.4 | 70.4 |
5 | BARTLETT 1 | TX0120421 | SWISHER COUNTY | AMARILLO | TX | NA | 00000 | NA | Swisher | 06 | NA | -96.36552 | NON-POTW | NA | NA | NA | NA | NA | NA | N | NA | NA | NA | NA |
6 | BOSSIER PARISH RESOURCE CENTER | LAG830191 | 3228 BARKDALE BLVD | BENTON | LA | NA | 71111 | LAG830000 | Bossier | 06 | NA | -96.28182 | NON-POTW | NA | NA | NA | NA | NA | NA | N | 0 | 62.7 | 38.2 | 43.6 |
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 FT 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 FT 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 FT 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 FT 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 FT 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 FT 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
.
echoWaterGetParams(term = "Oxygen, dissolved")
#> # A tibble: 5 x 2
#> ValueCode ValueDescription
#> <chr> <chr>
#> 1 00300 Oxygen, dissolved [DO]
#> 2 51646 Oxygen, dissolved [DO] maximum
#> 3 51645 Oxygen, dissolved [DO] minimum
#> 4 00301 Oxygen, dissolved percent saturation
#> 5 00399 Oxygen, dissolved, % of time violated
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.
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.
## Sample code only,
## This example requires the development
## version of ggplot2 with support for
## geom_sf()
library(ggplot2)
library(ggmap)
library(dplyr)
library(purrr)
library(sf)
library(ggrepel)
## Download data as a simple feature
df <- echoWaterGetFacilityInfo(xmin = '-96.407563', ymin = '30.554395',
xmax = '-96.25947', ymax = '30.751984',
output = 'sf')
## Download a basemap with gg_map
collegestation <- get_map(location = c(-96.387509, 30.583572,
-96.281422, 30.640008),
zoom = 14, maptype = "toner")
## Use coordinates to create label locations
df <- df %>%
mutate(
coords = map(geometry, st_coordinates),
coords_x = map_dbl(coords, 1),
coords_y = map_dbl(coords, 2)
)
## Make the map
ggmap(collegestation) +
geom_sf(data = df, inherit.aes = FALSE, shape = 21,
color = "darkred", fill = "darkred",
size = 2, alpha = 0.25) +
geom_label_repel(data = df, aes(x = coords_x, y = coords_y, label = SourceID),
point.padding = .5, min.segment.length = 0.1,
size = 2, color = "dodgerblue") +
labs(x = "Longitude", y = "Latitude",
title = "NPDES permits near Texas A&M",
caption = "Source: EPA ECHO database")