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, 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:
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:
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
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'))
#> Error in ejscreenRESTbroker(lon = -80, lat = 42, f = "report"): API URL does not seem to be accessible
  x = ejscreenRESTbroker(lon = -80, lat = 42)
#> Error in ejscreenRESTbroker(lon = -80, lat = 42): API URL does not seem to be accessible
  df = ejscreenRESTbroker2table(x)
#> Error: object 'x' not found
  class(df)
#> [1] "function"
  t(df)
#> Error in t.default(df): argument is not a matrix
  x = ejscreenRESTbroker(lon = -80, lat = 42)
#> Error in ejscreenRESTbroker(lon = -80, lat = 42): API URL does not seem to be accessible
  names(x)
#> Error: object 'x' not found
  x$url
#> Error: object 'x' not found
  x$status_code
#> Error: object 'x' not found
  names(jsonlite::fromJSON(rawToChar(x$content)))
#> Error: object 'x' not found
  names(jsonlite::fromJSON(rawToChar(x$content))$data)
#> Error: object 'x' not found
  names(jsonlite::fromJSON(rawToChar(x$content))$data$main)
#> Error: object 'x' not found
  names(jsonlite::fromJSON(rawToChar(x$content))$data$extras)
#> Error: object 'x' not found
  names(jsonlite::fromJSON(rawToChar(x$content))$data$demographics)
#> Error: object 'x' not found
  # }