2125
R-bloggers 2025-11-12
[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 12 of 30DayMapChallenge: « 2125 » (previously).
Vidaller et al. (2021) indicate that Pyrenean glaciers are in a clear imbalance with the regional climate and will likely disappear in the next few decades.
library(dplyr)library(ggplot2)library(glue)library(sf)library(elevatr)library(rnaturalearth)library(rnaturalearthhires)library(osmdata)library(terra)library(ggspatial)library(ggnewscale)library(ggrepel)sf_use_s2(FALSE)
Data
pyrenees <- getbb("Pyrénées", format_out = "sf_polygon")$polygonif (!file.exists("elevation_pyrenees.tif")) { get_elev_raster(pyrenees, z = 9) |> writeRaster("elevation_pyrenees.tif")}elevation_pyrenees <- rast("elevation_pyrenees.tif") elevation_pyrenees[elevation_pyrenees <=0] <- NA# map backgroundworld <- ne_countries(scale = 10) |> st_intersection(elevation_pyrenees |> st_bbox() |> st_as_sfc())slope <- terrain(elevation_pyrenees, "slope", unit = "radians")aspect <- terrain(elevation_pyrenees, "aspect", unit = "radians")hillshade <- shade(slope, aspect, angle = 45, direction = 315, normalize = TRUE)
Map
# we create a void layer to train the scale and have a legend glaciers <- st_polygon() |> st_sfc() |> st_sf() |> st_set_crs("EPSG:4326") |> mutate(glaciers = NA_character_)ggplot() + geom_sf(data = world, fill = "#c4c4c4", color = "#c4c4c4") + layer_spatial(hillshade) + scale_fill_distiller(palette = "Greys", guide = "none", na.value = "transparent") + geom_sf(data = world, fill = NA, color = "#333333") + new_scale_fill() + geom_sf(data = glaciers, aes(fill = glaciers)) + scale_fill_brewer(palette="RdYlBu", na.value="blue") + geom_text_repel(data = world, aes(label = sovereignt, geometry = geometry), stat = "sf_coordinates", color = "#333333", bg.colour = "#ffffffaa", bg.r = .2, alpha = 0.4) + coord_sf() + labs(title = "Pyrenean glaciers", subtitle = "2125", x = "", y = "", caption = glue("https://r.iresmi.net/ - {Sys.Date()} Elevation data from // https://registry.opendata.aws/terrain-tiles Natural Earth")) + theme_minimal() + theme(plot.caption = element_text(size = 6, color = "darkgrey"), legend.position = "bottom", legend.text = element_blank())

A sad map for sure…
References
Vidaller, I., J. Revuelto, E. Izagirre, F. Rojas-Heredia, E. Alonso-González, S. Gascoin, P. René, et al. 2021. “Toward an Ice-Free Mountain Range: Demise of Pyrenean Glaciers During 2011–2020.” Geophysical Research Letters 48 (18): e2021GL094339. https://doi.org/10.1029/2021GL094339.
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.
