Low-level utility to query EJSCREEN API for one circular buffer - API may or may not be available
Source:R/ejscreenRESTbroker.R
ejscreenRESTbroker.RdUse EJSCREEN API to get raw json-format response, ready to be
parsed by ejscreenRESTbroker2table(). This function underlies higher level
functions like ejscreenapi() and overall ejscreenit()
Usage
ejscreenRESTbroker(
lon = NULL,
lat = NULL,
radius = 3,
fips = NULL,
namestr = "",
shapefile = NULL,
url = c("https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx?",
"https://ejscreen.epa.gov/mapper/ejscreenRESTbroker.aspx?")[1],
ipurl = "ejscreen.epa.gov",
wkid = 4326,
unit = 9035,
f = "pjson",
reportstyle = c("EJscreen_SOE_report", "EJSCREEN_report")[1]
)Arguments
- lon
a longitude
- lat
a latitude
- radius
radius of the circular buffer (normally in miles)
- fips
If specified, lon and lat are ignored, and the one fips code must be the FIPS code of a blockgroup or tract, or county (5 digits with leading zero) or city/town/cdp/etc. (7 digits with leading zero). A character string is best, with leading zero if relevant.
- namestr
optional text
- shapefile
not implemented
- url
URL base for API (provides access to the shorter version vs default longer list of indicators), where newer 2023 version is default, using ejscreenRESTbroker1.aspx, and old style/mini version is at ejscreenRESTbroker.aspx
- ipurl
fixed ip or domain/URL to try
- wkid
spatial reference. https://epsg.io/4326
- unit
9035 for miles, 9036 for kilometers, but default is miles
- f
pjson for results in JSON format, or report for the URL of the pdf report
- reportstyle
EJscreen_SOE_report for the full community profile that was new as of 7/2023, but went down 1/2025, or EJSCREEN_report for the older style standard report (which has fewer indicators on it).
Details
Note the public and internal IP addresses differ.
API: Introduction to how the API works:
API URL was https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx? geometry= %22spatialReference%22:%22wkid%22:4326,%22x%22:-100.2,%22y%22:36 &distance=1&unit=9035&f=json
for example of json output format, or see source code of this function.
API URL was https://ejscreen.epa.gov/mapper/EJscreen_SOE_report.aspx?namestr= &geometry= %22spatialReference%22:%22wkid%22:4326,%22x%22:-100.12811027526683,%22y%22:36.6582500495267 &distance=10&unit=9035&areatype=&areaid=&f=report
Note some variables are duplicated in outputs.
API: Simple web interface to try out the API and learn how parameters can be specified in URL:
2023_07 ver 2.2 was at "https://ejscreen.epa.gov/mapper/ejscreenapi1.html"
old style/mini ver 2.2 (fewer indicators) was at "https://ejscreen.epa.gov/mapper/ejscreenapi.html"
API: REST endpoint:
2023_07 ver 2.2 was at "https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx?namestr="
old style/mini ver 2.2 was at "https://ejscreen.epa.gov/mapper/ejscreenRESTbroker.aspx?namestr="
csv/gdb files: Data dictionary for downloadable dataset:
2023_07 ver 2.2 was at "https://gaftp.epa.gov/EJScreen/2023/EJSCREEN_2023_BG_Columns.xlsx"
API: Data dictionary of variable names:
2023_07 ver 2.2 was at "https://ejscreen.epa.gov/mapper/ejsoefielddesc1.html"
old style/mini ver 2.2 was at "https://ejscreen.epa.gov/mapper/ejsoefielddesc.html"
Webpage explaining the indicators
ver 2.2 was at "https://origin-awswest-www.epa.gov/ejscreen/ejscreen-map-descriptions"
Web tool user guide:
2023_07 ver 2.2 was at "https://ejscreen.epa.gov/mapper/help/ejscreen_help.pdf"
See also
ejscreenit() or
ejscreenit() which use ejscreenapi_plus()
and that uses ejscreenapi() that uses ejscreenapi1() and ejscreenRESTbroker() and ejscreenRESTbroker2table()
Examples
# \donttest{
browseURL(ejscreenRESTbroker(lon = -80, lat = 42, f = 'report'))
x = ejscreenRESTbroker(lon = -80, lat = 42)
df = ejscreenRESTbroker2table(x)
class(df)
t(df)
x = ejscreenRESTbroker(lon = -80, lat = 42)
names(x)
x$url
x$status_code
names(jsonlite::fromJSON(rawToChar(x$content)))
names(jsonlite::fromJSON(rawToChar(x$content))$data)
names(jsonlite::fromJSON(rawToChar(x$content))$data$main)
names(jsonlite::fromJSON(rawToChar(x$content))$data$extras)
names(jsonlite::fromJSON(rawToChar(x$content))$data$demographics)
# }