Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created November 6, 2025 17:13
Show Gist options
  • Select an option

  • Save walkerke/d5f3947e9d560fc32d89b9e7fa584a9c to your computer and use it in GitHub Desktop.

Select an option

Save walkerke/d5f3947e9d560fc32d89b9e7fa584a9c to your computer and use it in GitHub Desktop.
library(tidycensus)
library(mapgl)
tx_income <- get_acs(
geography = "tract",
variables = "B19013_001",
state = "TX",
geometry = TRUE
)
pal <- interpolate_palette(tx_income, "estimate", palette = function(x) {
scico::scico(x, palette = "oslo", direction = -1)
})
maplibre(bounds = tx_income, style = openfreemap_style("positron")) |>
add_fill_extrusion_layer(
id = "tracts",
source = tx_income,
fill_extrusion_color = pal$expression,
fill_extrusion_height = interpolate(
column = "estimate",
values = c(0, 250002),
stops = c(0, 10000)
)
) |>
add_continuous_legend(
"Median household income",
values = get_legend_labels(pal, format = "compact", prefix = "$"),
colors = get_legend_colors(pal),
width = "300px"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment