Skip to contents

export EJAM results as geojson/zipped shapefile/kml for use in ArcPro, EJScreen, etc.

Usage

ejam2shapefile(
  ejamitout,
  file = "EJAM_results_bysite_date_time.geojson",
  folder = tempdir(),
  save = TRUE,
  crs = 4269,
  shortcolnames = TRUE,
  varnames = "basic250",
  shp = NULL
)

Arguments

ejamitout

output of EJAM such as from ejamit()

file

optional filename with no path, with extension one of "geojson"/"json", "shp", "zip", "kml" (where zip and shp both mean a .zip file that is a zipped set of .shp format files) Ignored if save=F.

folder

optional - If omitted (and not running in shiny and if interactive() mode), this function prompts you to specify the folder where the file should be saved. If omitted and not running in shiny or not interactive() mode, it uses tempdir(). Ignored if save=F.

save

whether to save file - if FALSE, it returns the object not the file path

crs

optional coord ref system

shortcolnames

Whether to cut colnames to 10 characters only if using .shp format

varnames

optional vector of which colnames of ejamitout$results_bysite to include in shapefile. DJefault is all other than averages, ratios, and raw EJ scores. Can be "all" or NULL to include all columns.

shp

data.frame that is also "sf" class, with "geometry" column for mapping, rows exactly corresponding to those in ejamitout$results_bysite

Value

path to saved file

Details

FIELD NAMES (indicator names) CURRENTLY ARE TRUNCATED AND NUMBERED TO BE ONLY 10 CHARACTERS MAX.

see Shapefile format basics from arcgis.com

Examples

# \donttest{
  # folder = getwd()
  # out <- ejamit(testpoints_100 , radius = 3.1)
  # file <- ejam2shapefile(out, file = "test100_3miles.geojson", folder = folder)

  out <- testoutput_ejamit_10pts_1miles
  file <- ejam2shapefile(out)
#> Using only basic 250 or so columns -
#> To include averages, ratios, and raw EJ scores, set varnames = 'all' or NULL.
#> To include specific columns provides those as a character vector of varnames.
#> input was not a simple feature object, but will convert to one
#> Writing layer `RtmpuU15oN\EJAM_results_bysite_20250523_202659' to data source 
#>   `/tmp/RtmpuU15oN\EJAM_results_bysite_20250523_202659.geojson' using driver `GeoJSON'
#> Writing 10 features with 289 fields and geometry type Polygon.
  shp <- shapefile_from_any(file)
#> Reading layer `RtmpuU15oN\EJAM_results_bysite_20250523_202659' from data source 
#>   `/tmp/RtmpuU15oN\EJAM_results_bysite_20250523_202659.geojson' 
#>   using driver `GeoJSON'
#> Simple feature collection with 10 features and 289 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -122.429 ymin: 33.13401 xmax: -72.64326 ymax: 45.68949
#> Geodetic CRS:  NAD83
#> Warning: ejam_uniq_id columns was already in shp, but replacing it now!
  map_shapes_leaflet(shp)
#> Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
#> Need '+proj=longlat +datum=WGS84'
# }