Casiquiare
[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: « South America » (previously).
Do you know you can circumnavigate the Guiana shield? There is a river, the Rio Casiquiare, that connects the Orinoco and the Amazon basin! If you need a map for your next adventure, in the “footsteps” of Alexander von Humboldt, here it is…
We pick the OpenStreetMap ID of the river relations (e.g.: https://www.openstreetmap.org/relation/2295651), make a data.frame
of the rivers geometry and plot it.
library(tidyverse) library(sf) library(rnaturalearth) library(osmdata) library(ggspatial) library(ggrepel) countries <- ne_countries(scale = 50, returnclass = "sf") rivers <- tribble(~name, ~relation, "Rio Casiquiare", 275909, "Orinoco", 1083284, "Rio Negro", 275660, "Rio Amazonas", 2295651) |> mutate(geometry = map(relation, \(r) paste0("relation/", r) |> opq_osm_id() |> opq_string () |> osmdata_sf () |> pluck("osm_lines", "geometry") |> st_union() |> st_geometrycollection())) |> st_sf(crs = "EPSG:4326")
ggplot() + geom_sf(data = countries, color = "gray80", fill = "gray95") + geom_sf(data = rivers, aes(color = name), linewidth = .8, key_glyph = "smooth") + geom_text_repel(data = countries |> filter(adm0_a3 %in% c("BRA", "GUY", "VEN", "SUR", "COL", "PER")), aes(label = name, geometry = geometry), stat = "sf_coordinates", size = 2.5) + scale_color_manual(name = "river", values = c("Rio Casiquiare" = "firebrick3", "Orinoco" = "cyan4", "Rio Negro" = "gray10", "Rio Amazonas" = "burlywood2")) + coord_sf(xlim = c(-81, -36), ylim = c(-20, 12)) + labs(title = "Circumnavigating the Guiana shield", caption = "Approximate scale\nData: Openstreetmap contributors\nBasemap: Natural Earth\nhttps://r.iresmi.net/", x = "", y = "") + annotation_scale(height = unit(1, "mm")) + theme(panel.background = element_rect(fill = "azure"), panel.grid = element_line(color = "azure2"), legend.key = element_rect(fill = NA), plot.caption = element_text(size = 6))
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.