Get EJScreen report results for one circular buffer, as a data.frame
Usage
ejscreenapi1(
lon,
lat,
radius = 3,
unit = "miles",
wkid = 4326,
fips = NULL,
shapefile = NULL,
namestr = "",
format_report_or_json = "pjson",
ipurl = "ejscreen.epa.gov",
getstatefromplacename = TRUE
)
Arguments
- lon
Longitude numeric
- lat
Latitude numeric
- radius
radius, in miles, of circular buffer
- unit
miles (default) or kilometers
- wkid
optional spatial reference code. https://epsg.io/4326
- fips
if used instead of lon,lat it should be a character FIPS code (counties, tracts, or blockgroups)
- shapefile
not implemented
- namestr
optional text used on report if fips provided and you want to show this text instead of the FIPS code on the report
- format_report_or_json
default is "pjson" but could "report" to get URL for a pdf report
- ipurl
IP or URL start
- getstatefromplacename
set to FALSE if you need the exact output of API and TRUE if you want to try to extract ST abbrev and statename from the placename field, which is more likely to be correct than the stateAbbr and stateName fields in the API output.
Details
Specify a radius and vector of latitude longitude points, and get for a buffer the population weighted mean value of each raw indicator like percent low-income, and total population count, and percentiles for those raw indicator scores, all from EJScreen, as in an EJScreen standard report.
Note that this API is fairly slow, so it is fine for 10 sites, but not large numbers.
Relies on ejscreenRESTbroker()
for the actual request via API,
and ejscreenRESTbroker2table()
to format it and handle errors.
It essentially does this: ejscreenRESTbroker2table(ejscreenRESTbroker()) And then it adds the columns "pdf_report" and "pdf_acs_report"
It returns a 1-row data.frame
and makes relevant columns values numeric, and converts text like 45% to the number 45.
It also drops redundant columns where the same numbers had been returned from API using the normal name and a synonym name, as with TOTALPOP and "totalPop"
See (https://web.archive.org/web/20250118193121/https://www.epa.gov/ejscreen/ejscreen-api)
See also
ejscreenit()
ejscreenapi_plus()
ejscreenapi()
that uses ejscreenapi1()
and ejscreenRESTbroker()
and ejscreenRESTbroker2table()
Examples
if (FALSE) { # \dontrun{
# Specify size of buffer circle and pick random points as example data
myradius <- 1
pts <- structure(list(lon = c(-96.4798957, -111.7674343, -75.4173589,
-95.9573172, -87.8402677, -77.9996191, -73.920702, -79.9545638,
-76.0638877, -114.9881473), lat = c(31.782716, 33.7522735, 39.8697972,
33.2522474, 41.9763992, 38.4661259, 41.2940801, 32.8099327, 40.9888266,
36.0043628), id = 1:10), row.names = c(NA, -10L), class = "data.frame")
out1 <- ejscreenapi1(lon = pts$lon[1], lat=pts$lat[1], radius = myradius)
t(out1)
#out <- ejscreenapi(lon=pts$lon, lat=pts$lat, radius = myradius)
#t(out[1:2,])
} # }