Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created July 25, 2024 21:02
Show Gist options
  • Save walkerke/aaec99a81f145461431d9f2c8fe8792c to your computer and use it in GitHub Desktop.
Save walkerke/aaec99a81f145461431d9f2c8fe8792c to your computer and use it in GitHub Desktop.
library(mapgl)
library(tidycensus)
options(tigris_use_cache = TRUE)
tarrant_income <- get_acs(
geography = "tract",
variables = "B19013_001",
state = "TX",
county = "Tarrant",
geometry = TRUE
)
tarrant_education <- get_acs(
geography = "tract",
variables = "DP02_0068P",
state = "TX",
county = "Tarrant",
geometry = TRUE
)
tarrant_age <- get_acs(
geography = "tract",
variables = "B01002_001",
state = "TX",
county = "Tarrant",
geometry = TRUE
)
mapboxgl(center = c(-97.2936, 32.7517),
zoom = 10,
pitch = 67,
bearing = -57.1) |>
add_fill_extrusion_layer(
id = "Median HH income",
source = tarrant_income,
fill_extrusion_color = interpolate(
"estimate",
values = c(0, 250001),
stops = c("lightgreen", "darkgreen")
),
fill_extrusion_base = 3000
) |>
add_fill_extrusion_layer(
id = "% with college degree",
source = tarrant_education,
fill_extrusion_color = interpolate(
"estimate",
values = c(0, 75),
stops = c("lightblue", "darkblue")
),
fill_extrusion_base = 9000
) |>
add_fill_extrusion_layer(
id = "Median age",
source = tarrant_age,
fill_extrusion_color = interpolate(
"estimate",
values = c(0, 75),
stops = c("lightpink", "maroon")
),
fill_extrusion_base = 15000
) |>
add_layers_control(collapsible = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment