Reversed

[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.

A photo of beach seen through a glass ball

Calvi – Noël 2017 – CC-BY-NC-NA by Valerie Hukalo

Day 5 of 30DayMapChallenge: « Earth » (previously).

What if the bathymetry of the Mediterranean Sea is reversed? We would get a Western Island and an Eastern Island, a Sardinia-Corsica Bay, the Balearic Lagoon… Let’s see!

library(terra)
library(sf)

terraOptions(progress=0)

A global bathymetry dataset (7.5 Go zipped NetCDF) is available at GEBCO. We crop it around the Mediterranean Sea.

med <- c(xmin = -7, ymin = 30, xmax = 39,  ymax = 45) |> 
  st_bbox() |> 
  st_as_sfc()

gebco <- rast("~/data/gebco/GEBCO_2025_sub_ice.nc") |> 
  crop(med) 

We set all positive values to 0 and all negative values are inversed. The relief is more pronounced with a light lower resolution, then we compute the hillshading.

mountain_med <- aggregate((gebco <= 0) * -1 * gebco, 10, mean)
slope <- terrain(mountain_med, "slope", unit = "radians")
aspect <- terrain(mountain_med, "aspect", unit = "radians")
hill <- shade(slope, aspect, angle = 45, direction = 315, normalize = TRUE)

Map

plot(hill, col = grey(0:255/255), 
     main = "Mediterranean Sea upside down",
     legend = FALSE, mar = c(2,2,2,4))
plot(mountain_med, col = topo.colors(30, alpha = 0.3),
     plg = list(title = "Elevation (m)"), add = TRUE)
mtext(paste("data: GEBCO\nhttps://r.iresmi.net", Sys.Date()), 
            side = 1, line = 3, cex = 0.5, adj = 1) 
Map of inverted Mediterranean elevation
Figure 1: Mediterranean Sea upside down
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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)