[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.
Day 1 of 30 Day Card Challenge: « Points ».
Mapping the peaks above 8000 m, also known as the eight-thousanders.
Configuration
library(httr) library(glue) library(dplyr) library(tidyr) library(purrr) library(tibble) library(stringr) library(sf) library(leaflet)
Several non-trivial options for getting the data:
- English Wikipedia does not have the geographic coordinates to delete (although Wikipedia in other languages does);
- I can’t get a working SPARQL query on Wikidata (lack of knowledge on my part), even with the help of SPINACH Wikidata Agent;
- there is no easy OpenStreetMap relationship with importing;
- so in the end I resorted to making one directly Viaduct API call, although {osmdata} should have worked too.
Using a Himalayan and Karakoram boundary, we keep the peaks above 8000 m with prominence > 500 m (major peaks, otherwise we would get several secondary peaks).
It takes about 1 minute…
overpass_query <- URLencode(r"([out:json][timeout:250];
node
["natural"="peak"]
(25,70,38,98)
["ele"]
["prominence"]
(if:number(t["prominence"]) > 500 && number(t["ele"]) > 8000);
out body;)", reserved = TRUE)
summits <- GET(glue("https://overpass-api.de/api/interpreter?data={overpass_query}"))
summits_sf <- content(summits) |>
pluck("elements") |>
map(unlist) |>
map(enframe) |>
map(pivot_wider) |>
list_rbind() |>
rename_with(\(x) str_replace(x, "^tags\\.", "")) |>
st_as_sf(coords = c("lon", "lat"), crs = "EPSG:4326")Table 1: The eight-thousanders
Simple feature collection with 14 features and 2 fields Geometry type: POINT Dimension: XY Bounding box: xmin: 74.58954 ymin: 27.70301 xmax: 88.14748 ymax: 35.88168 Geodetic CRS: WGS 84 # A tibble: 14 × 3 name elevation geometry1 Mount Everest 8848.86 (86.92521 27.98806) 2 K2 8611 (76.51333 35.88168) 3 Kangchenjunga 8586 (88.14748 27.70301) 4 Lhotse 8516 (86.9325 27.96199) 5 Mount Makalu 8485 (87.08844 27.89144) 6 Cho Oyu 8201 (86.65963 28.09675) 7 Dhaulagiri 8167 (83.48949 28.69761) 8 Manaslu 8163 (84.55973 28.54998) 9 Nanga Parbat 8126 (74.58954 35.23846) 10 Annapurna I 8091 (83.81992 28.59581) 11 Gasherbrum I 8080 (76.69762 35.72468) 12 Broad Peak 8051 (76.56556 35.81369) 13 Gasherbrum II 8034 (76.65327 35.75773) 14 Shishapangma 8027 (85.78207 28.35176)
summits_sf |>
leaflet() |>
addTiles(attribution = r"(
r.iresmi.net.
data and map: OpenStreetMap)") |>
addCircleMarkers(popup = ~ glue("{name} ({`name:en`})
{ele} m"),
clusterOptions = markerClusterOptions())Figure 1: The eight-thousanders
Related
#Eightthousanders #bloggers


