Map - points - Create leaflet html widget map of points using table with lat lon
Source:R/mapfast.R
mapfast.Rd
Map - points - Create leaflet html widget map of points using table with lat lon
Usage
mapfast(
mydf,
radius = 3,
column_names = "all",
labels = column_names,
browse = FALSE,
color = "#03F"
)
Arguments
- mydf
Typically something like the output of ejamit()$results_bysite, but can also be the full output of
ejamit()
in which case this uses just the $results_bysite table, and in general mydf can be a data.frame or data.table that has a set of points or polygons or Census FIPS codes.point data defined by columns named lat and lon, or columns that
latlon_infer()
can infer to be that, as fromsitepoints_from_any()
orejamit()
$results_bysitepolygon data in a spatial data.frame that has a geometry column of polygons, as from
shapefile_from_any()
, orCensus units defined by FIPS codes in a column called "ejam_uniq_id" (not fips), where those fips are for States, Counties, Tracts, Blockgroups, or cities/towns/Census Designated Places (7 digits including any leading zeroes), e.g., as from names2fips('DE') or ejamit(fips='01')$results_bysite.
- radius
in miles, converted to meters and passed to leaflet::addCircles()
- column_names
If "ej" then nice popup made based on just key EJScreen indicators. If "all" then every column in the entire mydf table is shown in the popup. If a vector of colnames, only those are shown in popups.
- labels
The labels used before the column_names, for map popups, like label: column_name (ignored if column_names is ej or all)
- browse
optional logical, set to TRUE if you want the function to launch a default browser window to show the map and print the temp filepath and filename in the console. Normally the map would be shown in the default RStudio viewer pane.
- color
color of circles or polygons
Examples
pts = testpoints_100
mapfast(pts)
# out = ejamit(pts, radius = 1)
out = testoutput_ejamit_100pts_1miles
# See in RStudio viewer pane
ejam2map(out)
mapfastej(out$results_bysite[c(12,31),])
if (FALSE) { # \dontrun{
# See in local browser instead
ejam2map(out, browse = T)
# Open folder where interactive map
# .html file is saved, so you can share it:
x = ejam2map(out)
fname = map2browser(x)
# browseURL(dirname(fname)) # to open the temp folder
# file.copy(fname, "./map.html") # to copy map file to working directory
out <- testoutput_ejscreenapi_plus_5
mapfastej(out)
} # }