Takes the output of ejamit() and maps the analyzed sites, using circles for point locations or polygons for shapefile and FIPS results.
Usage
ejam2map(
ejamitout,
column_names = "ej",
launch_browser = TRUE,
shp = NULL,
radius = NULL,
sitenumber = NULL,
shape = NULL,
shapefile = NULL,
buffer = NULL,
color = NULL,
sitenumber_label = NULL,
popup_style = "auto"
)Arguments
- ejamitout
output of ejamit()
- column_names
can be "ej", passed to
mapfast()- launch_browser
logical optional whether to open the web browser to view the map
- shp
shapefile it can map if analysis was for polygons, for example
- radius
optional radius in miles
- sitenumber
Optional integer. If a valid positive integer is provided, only that one site (row
sitenumberofejamitout$results_bysite) is mapped. If omitted, NULL, zero, negative, or out of range, all sites are mapped. Rows of invalid sites count, sinceresults_bysitehas one row per input site: with 4 sites of which the 2nd is invalid,sitenumber = 4maps the 4th. If the chosen site is invalid, there is a warning and the map may be empty. Works for all site types (latlon, fips, shp): whensitetypeis "fips" andshpis provided, both the results table andshpare subsetted to the requested row; whenshpis not provided, the FIPS polygon is downloaded for only that one site.- shape
alias (synonym) for shp
- shapefile
alias (synonym) for shp
- buffer
alias (synonym) for radius
- color
A column name in
ejamitout$results_bysite, a single R color, or a vector of colors in the same order as the rows being mapped. Percentile and ratio columns are converted to binned colors using internal helperspctile2color()andratio2color(); other numeric columns use a continuous viridis palette. An unknown column name that is not a valid R color causes an error. When selecting one sitenumber, supply that site's color or the column name. NULL (the default) keeps the map helper's usual blue:"#03F"for point circles or"#000080"for shapefile/FIPS polygons. Missing values in a color column are shown in light gray. These point/polygon maps do not automatically add a percentile legend; seemapfastej_counties()for a county choropleth with a legend.- sitenumber_label
optional, display-only override (a number or short text) of the site number shown in map popups, in place of the auto-assigned row number/ejam_uniq_id. Only relevant when mapping a single site – see
ejam2report(), whose sitenumber_label parameter this supports.- popup_style
"auto","full","short", or"none"(no popups)."auto"gives short popups when there are more thandefault_max_pts_show_detailed_popupssites. Seemap_popup_style()andmap_size_setting(). Points are also shown as clustered markers when there are more thandefault_max_pts_map_show_unclustered, and many polygons are simplified for the map.
Value
like what mapfastej() returns
Details
Gets radius from ejamitout$results_bysite$radius.miles. Use launch_browser = TRUE to save it as a shareable .html file and see it in your web browser.
Examples
pts <- testpoints_100
pts <- pts[is.finite(pts$lat) & is.finite(pts$lon), ]
mapfast(pts)
# out = ejamit(pts, radius = 1)
out <- testoutput_ejamit_100pts_1miles
# Use valid sites so the color vector matches the rows being mapped.
out$results_bysite <- out$results_bysite[out$results_bysite$valid %in% TRUE, ]
# See in RStudio viewer pane
ejam2map(out, launch_browser = FALSE)
# Color by a percentile column without manually converting its values.
ejam2map(out, color = "state.pctile.o3", launch_browser = FALSE)
mapfastej(out$results_bysite[c(12,31),])
# color-code points on map to show which ones had a high indicator score
mapfastej(out, color = EJAM:::ratio2color( out$results_bysite$ratio.to.state.avg.traffic.score))
mapfastej(out, color = EJAM:::pctile2color( out$results_bysite$state.pctile.o3))
mapfastej(out, color = EJAM:::pctile2color(out$results_bysite$pctile.Demog.Index.Supp))
if (FALSE) { # \dontrun{
out <- ejamit(fips = fips_counties_from_state_abbrev(c('KY', 'IN')))
ejam2map(out, color = EJAM:::pctile2color( out$results_bysite$state.pctile.o3))
# See in local browser instead
ejam2map(out)
# Open folder where interactive map
# .html file is saved, so you can share it:
x = ejam2map(out)
fname = map2browser(x)
# browseURL(normalizePath(dirname(fname))) # to open the temp folder
# file.copy(fname, "./map.html") # to copy map file to working directory
} # }