Skip to contents

Map - County polygons / boundaries - Create leaflet or static map of results of analysis

Usage

mapfastej_counties(
  mydf,
  colorvarname = "pctile.Demog.Index.Supp",
  colorfills = c("yellow", "orange", "red"),
  colorlabels = c(80, 90, 95),
  colorbins = c(80, 90, 95),
  colorpalette = c("yellow", "yellow", "orange", "red"),
  static_not_leaflet = FALSE,
  main = "Selected Counties",
  ...
)

Arguments

mydf

something like ejamit(fips = fips_counties_from_statename("Kentucky"), radius = 0)$results_bysite

colorvarname

colname of indicator in mydf that drives color-coding (or alternatively, colorvarname = "green" means a single specific color for all, like "green")

colorfills

= c('yellow', 'orange', 'red')

colorlabels

= c(80, 90, 95)

colorbins

= c(80, 90, 95)

colorpalette

= c("yellow", "yellow", "orange", "red")

static_not_leaflet

set TRUE to use map_shapes_plot() instead of map_shapes_leaflet()

main

title for map

...

passed to map_shapes_plot() if relevant

Value

leaflet html widget (but if static_not_leaflet=T, returns just shapes_counties_from_countyfips(mydf$ejam_uniq_id))

Details

THIS ASSUMES THAT mydf$ejam_unique_id is the county FIPS codes

Examples

# \donttest{
 fips_ky <- fips_counties_from_statename("Kentucky")
 x <- ejamit(fips = fips_ky, radius = 0)
#> Finding blocks in each FIPS Census unit.
#> Joining with `by = join_by(blockid)`
#> Aggregating at each FIPS Census unit and overall.
 mapfastej_counties(x$results_bysite)
#> Warning: need tidycensus package and census API key to use myservice = 'cartographic', so using default service instead
#> Reading layer `OGRGeoJSON' from data source 
#>   `https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Boundaries_2022/FeatureServer/2/query?where=FIPS%3D%2721001%27%20OR%20FIPS%3D%2721003%27%20OR%20FIPS%3D%2721005%27%20OR%20FIPS%3D%2721007%27%20OR%20FIPS%3D%2721009%27%20OR%20FIPS%3D%2721011%27%20OR%20FIPS%3D%2721013%27%20OR%20FIPS%3D%2721015%27%20OR%20FIPS%3D%2721017%27%20OR%20FIPS%3D%2721019%27%20OR%20FIPS%3D%2721021%27%20OR%20FIPS%3D%2721023%27%20OR%20FIPS%3D%2721025%27%20OR%20FIPS%3D%2721027%27%20OR%20FIPS%3D%2721029%27%20OR%20FIPS%3D%2721031%27%20OR%20FIPS%3D%2721033%27%20OR%20FIPS%3D%2721035%27%20OR%20FIPS%3D%2721037%27%20OR%20FIPS%3D%2721039%27%20OR%20FIPS%3D%2721041%27%20OR%20FIPS%3D%2721043%27%20OR%20FIPS%3D%2721045%27%20OR%20FIPS%3D%2721047%27%20OR%20FIPS%3D%2721049%27%20OR%20FIPS%3D%2721051%27%20OR%20FIPS%3D%2721053%27%20OR%20FIPS%3D%2721055%27%20OR%20FIPS%3D%2721057%27%20OR%20FIPS%3D%2721059%27%20OR%20FIPS%3D%2721061%27%20OR%20FIPS%3D%2721063%27%20OR%20FIPS%3D%2721065%27%20OR%20FIPS%3D%2721067%27%20OR%20FIPS%3D%2721069%27%20OR%20FIPS%3D%2721071%27%20OR%20FIPS%3D%2721073%27%20OR%20FIPS%3D%2721075%27%20OR%20FIPS%3D%2721077%27%20OR%20FIPS%3D%2721079%27%20OR%20FIPS%3D%2721081%27%20OR%20FIPS%3D%2721083%27%20OR%20FIPS%3D%2721085%27%20OR%20FIPS%3D%2721087%27%20OR%20FIPS%3D%2721089%27%20OR%20FIPS%3D%2721091%27%20OR%20FIPS%3D%2721093%27%20OR%20FIPS%3D%2721095%27%20OR%20FIPS%3D%2721097%27%20OR%20FIPS%3D%2721099%27&outFields=NAME%2CFIPS%2CSTATE_ABBR%2CSTATE_NAME%2CPOP_SQMI&returnGeometry=true&f=geojson' 
#>   using driver `GeoJSON'
#> Simple feature collection with 50 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.57121 ymin: 36.49706 xmax: -82.56356 ymax: 39.14774
#> Geodetic CRS:  WGS 84
#> Reading layer `OGRGeoJSON' from data source 
#>   `https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Boundaries_2022/FeatureServer/2/query?where=FIPS%3D%2721101%27%20OR%20FIPS%3D%2721103%27%20OR%20FIPS%3D%2721105%27%20OR%20FIPS%3D%2721107%27%20OR%20FIPS%3D%2721109%27%20OR%20FIPS%3D%2721111%27%20OR%20FIPS%3D%2721113%27%20OR%20FIPS%3D%2721115%27%20OR%20FIPS%3D%2721117%27%20OR%20FIPS%3D%2721119%27%20OR%20FIPS%3D%2721121%27%20OR%20FIPS%3D%2721123%27%20OR%20FIPS%3D%2721125%27%20OR%20FIPS%3D%2721127%27%20OR%20FIPS%3D%2721129%27%20OR%20FIPS%3D%2721131%27%20OR%20FIPS%3D%2721133%27%20OR%20FIPS%3D%2721135%27%20OR%20FIPS%3D%2721137%27%20OR%20FIPS%3D%2721139%27%20OR%20FIPS%3D%2721141%27%20OR%20FIPS%3D%2721143%27%20OR%20FIPS%3D%2721145%27%20OR%20FIPS%3D%2721147%27%20OR%20FIPS%3D%2721149%27%20OR%20FIPS%3D%2721151%27%20OR%20FIPS%3D%2721153%27%20OR%20FIPS%3D%2721155%27%20OR%20FIPS%3D%2721157%27%20OR%20FIPS%3D%2721159%27%20OR%20FIPS%3D%2721161%27%20OR%20FIPS%3D%2721163%27%20OR%20FIPS%3D%2721165%27%20OR%20FIPS%3D%2721167%27%20OR%20FIPS%3D%2721169%27%20OR%20FIPS%3D%2721171%27%20OR%20FIPS%3D%2721173%27%20OR%20FIPS%3D%2721175%27%20OR%20FIPS%3D%2721177%27%20OR%20FIPS%3D%2721179%27%20OR%20FIPS%3D%2721181%27%20OR%20FIPS%3D%2721183%27%20OR%20FIPS%3D%2721185%27%20OR%20FIPS%3D%2721187%27%20OR%20FIPS%3D%2721189%27%20OR%20FIPS%3D%2721191%27%20OR%20FIPS%3D%2721193%27%20OR%20FIPS%3D%2721195%27%20OR%20FIPS%3D%2721197%27%20OR%20FIPS%3D%2721199%27&outFields=NAME%2CFIPS%2CSTATE_ABBR%2CSTATE_NAME%2CPOP_SQMI&returnGeometry=true&f=geojson' 
#>   using driver `GeoJSON'
#> Simple feature collection with 50 features and 5 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.20141 ymin: 36.50262 xmax: -81.96479 ymax: 39.09998
#> Geodetic CRS:  WGS 84
#> Reading layer `OGRGeoJSON' from data source 
#>   `https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Boundaries_2022/FeatureServer/2/query?where=FIPS%3D%2721201%27%20OR%20FIPS%3D%2721203%27%20OR%20FIPS%3D%2721205%27%20OR%20FIPS%3D%2721207%27%20OR%20FIPS%3D%2721209%27%20OR%20FIPS%3D%2721211%27%20OR%20FIPS%3D%2721213%27%20OR%20FIPS%3D%2721215%27%20OR%20FIPS%3D%2721217%27%20OR%20FIPS%3D%2721219%27%20OR%20FIPS%3D%2721221%27%20OR%20FIPS%3D%2721223%27%20OR%20FIPS%3D%2721225%27%20OR%20FIPS%3D%2721227%27%20OR%20FIPS%3D%2721229%27%20OR%20FIPS%3D%2721231%27%20OR%20FIPS%3D%2721233%27%20OR%20FIPS%3D%2721235%27%20OR%20FIPS%3D%2721237%27%20OR%20FIPS%3D%2721239%27&outFields=NAME%2CFIPS%2CSTATE_ABBR%2CSTATE_NAME%2CPOP_SQMI&returnGeometry=true&f=geojson' 
#>   using driver `GeoJSON'
#> Simple feature collection with 20 features and 5 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -88.16031 ymin: 36.5877 xmax: -83.199 ymax: 38.73716
#> Geodetic CRS:  WGS 84
#> Warning: Some values were outside the color scale and will be treated as NA
# } # map_shapes_leaflet(shapes = shapes_counties_from_countyfips(fips_ky))