library(tidyverse)
library(tidycensus)
library(sf)
library(mapgl)
Using mapgl
First Map with mapgl
::mapboxgl(
mapglstyle = mapbox_style("satellite"),
projection = "winkelTripel"
)
::mapboxgl(
mapglstyle = mapbox_style("streets"),
projection = "winkelTripel"
%>%
) fly_to(
center = c(77.580643, 12.972442),
zoom = 18, pitch = 50, bearing = 140
)
maplibre(
style = maptiler_style("bright"),
center = c(77.580643, 12.972442),
zoom = 16,
# pitch = 50, bearing = 140
%>%
) add_fullscreen_control(position = "top-left") %>%
add_navigation_control()
<- get_acs(
fl_age geography = "tract",
variables = "B01002_001",
state = "FL",
year = 2022,
geometry = TRUE
)
| | | 0% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================= | 25% | |================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================= | 64% | |============================================= | 65% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |=================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |========================================================== | 84% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 86% | |============================================================= | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
fl_age
range(fl_age$estimate, na.rm = T)
[1] 19.1 81.9
<- maplibre(style = maptiler_style("basic"), bounds = fl_age)
fl_map
%>%
fl_map add_fill_layer(
id = "fl_tracts",
source = fl_age,
fill_color =
interpolate(
column = "estimate",
values = c(20, 80),
stops = c("lightblue", "darkblue"),
na_color = "lightgrey"
)%>%
) add_legend(
"Median Age in Florida",
values = c(20, 80),
colors = c("lightblue", "darkblue")
)
%>%
fl_map add_fill_layer(
id = "fl_tracts",
source = fl_age,
fill_color = step_expr(
column = "estimate",
values = c(20, 50, 80),
base = "white",
stops = c("lightblue", "blue", "darkblue"),
na_color = "lightgrey"
)%>%
) add_legend(
"Median Age in Florida",
values = c(20, 80),
colors = c("lightblue", "blue", "darkblue")
)