Get list of all MTB Trails world wide

All,

I’m (trying to) build a website that lists and displays all MTB (mountain bike) trails worldwide. I have several questions in this respect, I hope I can combine them in this one post. I feel like I don’t fully grasp what OSM is, and more importantly, isn’t. These are my questions:

  1. I installed osmpythontools, a python wrapper for the OSM API. Is there a way to list all MTB trails using this tool? If not are there other python wrappers or perhaps you have suggestions to do it with the raw API? (I’m kind of a Python person…)

  2. I noticed that other websites that display trails often load a (leaflet) OSM map and then project a route on top. The route comes from a local definition, not from OSM itself. I was hoping I could use routes that have been put on OSM before (so is this typical?).
    I uploaded a trail myself https://www.openstreetmap.org/user/FreekvH/traces/3578619 to try it out but I can’t get the map to display this route, how does one do this? If I press “view map” I only see a marker, not a trail (I’m on Firefox on Linux), is that normal?

I have more questions, but I think that if I understand these 2 things I can make some more steps in displaying MTB trails on my website.
Feel free to point me to additional reading materials, I feel a bit lost at the moment.

Highest regards,

Freek.

Some resources you may find useful:
Introduction to OSM for beginners https://learnosm.org/en/
Wiki page on mapping mountaing biking https://wiki.openstreetmap.org/wiki/Mountain_biking
Wiki page on MTB route relations https://wiki.openstreetmap.org/wiki/Tag:route%3Dmtb
Map displaying waymarked MTB routes https://mtb.waymarkedtrails.org/

The trail you uploaded is a GPS trace, this is just the starting point, it is not “mapped” just by uploading it. It can act as a guide for you or other people to add information about trails by editing the map data or adding to it. It looks like most of your route is already mapped as tracks and paths, but you might be able to add mtb information, especially if it is a signposted MTB route.

None of this addresses you question about python, but I think you need to understand the OSM database before you look at extracting information from it using python or any other tool.

Thank you, this is very helpful. I will read all the links.

I did by now manage to get some information from the API using osmpythontools, for specific “relations”, such as indeed the MTB trails that overlaps the trail I uploaded:


from OSMPythonTools.api import Api
api = Api()
way = api.query('relation/6754945')
way.tags()

=>
{'distance': '9.35',
 'name': 'MTB-route Dorst',
 'network': 'lcn',
 'operator': 'MTB Tracks Oosterhout',
 'roundtrip': 'yes',
 'route': 'mtb',
 'type': 'route',
 'website': 'https://www.mtbtracksoosterhout.nl/'}

I can also set my leaflet maps to the correct location (using Django). Now if I can just display the actual trail (“relation”), that would be great. For that I posted a question on stackoverflow: https://stackoverflow.com/questions/68248846/display-relation-trail-in-leaflet.

Thank you again for your swift answer.

Ok, I have learned a lot. I can now download relations and show them in Leaflet on my website. But now I would really like to do this for all relations with “‘route’: ‘mtb’” in their tags. Any pointers? I was trying:

[out:json][timeout:10000][bbox:{{bbox}}];
relation["route:mtb"];

out center;

On https://overpass-turbo.eu/, but it only returns empty datasets…

Does it work if you use “route” = “mtb” inside the square brackets instead of “route:mtb”?

It does indeed! Thank you very much!!

It does become a very large result and a long query (I really want to do the whole world). Any tips for being more efficient? I’d also hate to inconvenience OSM with huge API requests…

Another option would be to download all the OSM data from a mirror listed at https://planet.osm.org/ and then extract relations and ways with the tags “route=mtb” from that. It’s still a lot of data to process - 60GB of data to download and 20k MTB ways and relations to extract from it.

To extract data you can using something like https://wiki.openstreetmap.org/wiki/Osmium or https://wiki.openstreetmap.org/wiki/Osmosis .