2125 | R bloggers

2125 | R bloggers

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report a problem with 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.

Vungemal – CC-BY-NC-SA by Jon Larrañaga

Day 12 of 30 Day Card Challenge: « 2125 » (earlier).

Vidaller et al. (2021) indicate that the glaciers in the Pyrenees are clearly out of equilibrium with the regional climate and are likely to disappear in the coming 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)

Facts

pyrenees <- getbb("Pyrénées", format_out = "sf_polygon")$polygon

if (!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 background
world <- 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)

Card

# 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 map of the relief of the Pyrenees without a glacier remaining

Figure 1: Map of Pyrenean glaciers in 2025

Definitely a sad card…

References

Vidor, I., J. Revolution, E. Isagir, F. Royal Herith, E 2021. “Towards one Ice-free mountain range: Doom by Pyrenean glaciers during 2011–2020.” Geophysical research letters 48 (18): e2021GL094339. https://doi.org/10.1029/2021GL094339.


#bloggers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *