library(elevatr)
library(rnaturalearth)
# remotes::install_github("ropensci/rnaturalearthhires")
library(terra)
library(ggplot2)
library(ggridges)Day 2 of 30DayMapChallenge: « Lines » (previously).
Representing a digital elevation model as ridgelines…
Config
Data
ch <- ne_countries(scale = 10, country = "switzerland")
ele <- get_elev_raster(ch, z = 9)
names(ele) <- "z"Map
ele |>
mask(ch) |>
aggregate(fact = 20) |>
as.data.frame(xy = TRUE) |>
ggplot() +
geom_density_ridges(aes(x = x, y = y, group = y, height = z),
stat = "identity",
alpha = 0.3,
color = "red",
fill = "white",
scale = 10) +
labs(title = "Switzerland",
caption = paste("Elevation data from
https://registry.opendata.aws/terrain-tiles
https://r.iresmi.net/", Sys.Date())) +
theme_void() +
theme(plot.background = element_rect(fill = "grey"),
title = element_text(color = "red"),
plot.caption = element_text(color = "#777"),
plot.margin = margin(2, 2, 2, 5, unit = "mm"))
