Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created September 16, 2025 19:18
Show Gist options
  • Save walkerke/b77982bf2c64b29acc753dc293e60c97 to your computer and use it in GitHub Desktop.
Save walkerke/b77982bf2c64b29acc753dc293e60c97 to your computer and use it in GitHub Desktop.
library(mapgl)
library(tidycensus)
tarrant_age <- get_acs(
geography = "tract",
variables = "B01002_001",
state = "TX",
county = "Tarrant",
geometry = TRUE
)
palette <- interpolate_palette(
tarrant_age,
column = "estimate",
palette = viridisLite::cividis
)
maplibre(
style = carto_style("positron"),
bounds = tarrant_age
) |>
add_fill_layer(
id = "age-layer",
source = tarrant_age,
fill_color = palette$expression,
fill_opacity = 0.5
) |>
turf_center_of_mass(
layer_id = "age-layer",
source_id = "label-source"
) |>
add_symbol_layer(
id = "symbols",
source = "label-source",
text_field = concat("Tract: ", get_column("GEOID"),
"\nMedian: ", get_column("estimate")),
min_zoom = 13
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment