Skip to contents

Use 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, or EJSCREEN_report for the older style standard report (which has fewer indicators on it).

Value

Returns JSON by default. See source code of this function for notes on format. status_code

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 for an example of the pdf report output.

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:

API: REST endpoint:

csv/gdb files: Data dictionary for downloadable dataset:

API: Data dictionary of variable names:

Webpage explaining the indicators

Web tool user guide:

See also

ejscreenit() or ejscreenit() which use ejscreenapi_plus() and that uses ejscreenapi() that uses ejscreenapi1() and ejscreenRESTbroker() and ejscreenRESTbroker2table()

Examples

if (FALSE) { # \dontrun{
  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)
  } # }