Signposted hiking trails are relations of type route=hiking. Their members are the paths they follow. Here they are searched in a bounding box around Zermatt.
The query
[out:json][timeout:60]; rel["route"="hiking"](45.95,7.65,46.07,7.85); out geom;
Run it
Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).
How it works
- Routes are found when at least one member is inside the box, so long-distance trails come out whole.
- The
networktag says the level:iwninternational,nwnnational,rwnregional,lwnlocal.
Variations
- Only national trails: add
["network"="nwn"]. - Mountain hiking difficulty is on the paths:
way["sac_scale"]. - Distance, ascent and descent of one route: elevation profile of a hiking route.
Run it from your code
curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
--data-urlencode 'data@query.overpassql'
import requests
query = open("query.overpassql").read()
r = requests.post("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter",
data={"data": query}, timeout=120)
r.raise_for_status()
print(r.json()["elements"][:3])
const res = await fetch("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter", {
method: "POST",
body: new URLSearchParams({ data: query }),
});
if (!res.ok) throw new Error(await res.text());
console.log(await res.json());
Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.