Maplibre
[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Day 17 of 30DayMapChallenge: « A new tool » (previously).
Testing Maplibre with {mapgl}.
library(dplyr) library(mapgl) library(sf)
Data
Using french communes population.
pop <- read_sf("~/data/adminexpress/adminexpress-cog-simpl-000-2024.gpkg",
layer = "commune") |>
st_centroid() |>
select(population)
Map
maplibre(center = c(5, 45),
zoom = 6) |>
add_heatmap_layer(
id = "pop",
source = pop,
heatmap_weight = interpolate(
column = "population",
values = c(0, max(pop$population)),
stops = c(0, 30)),
heatmap_intensity = interpolate(
property = "zoom",
values = c(0, 1),
stops = c(9, 3)),
heatmap_color = interpolate(
property = "heatmap-density",
values = seq(0, 1, 0.2),
stops = c(
"rgba(33,102,172,0)", "rgb(103,169,207)",
"rgb(209,229,240)", "rgb(253,219,199)",
"rgb(239,138,98)", "rgb(178,24,43)")),
heatmap_opacity = 0.7
)
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.