I would like to ride my bicycle on an old rail trail but I would like to know the distance from end to end. I cannot find the information anywhere online and OSM has the entire abandoned rail trail on the map. I just need to know the distance so I can measure out my time to complete it in. How can this be achieved?
When it is a marked trail https://cycling.waymarkedtrails.org/ might help.
If the entirety of your trail is actually one relation in OSM, like this
(which happens to have a distance=415
tag but let’s assume it did not)
then you can use the “Postpass” database to query the length of this relation like so
curl -g https://postpass.geofabrik.de/api/0.2/interpreter \
--data-urlencode "options[geojson]=false"
--data-urlencode "data=
SELECT st_length(geom::geography) AS length
FROM postpass_line
WHERE osm_type='R'
AND osm_id=9940"
And the result is then
{
"result": [
{
"length": 406115.58365048736
}
}
You can also use “Overpass Turbo” to execute this query: overpass turbo (click on the line in the map to show a popup with the length).
If, however, you want to travel only part of a relation or maybe something that isn’t one complete relation, I suggest heading over to https://routing.openstreetmap.de/, select your start and destination and bicycle routing mode, and in case it doesn’t pick the trail you want to travel along you can grab the route in the middle and force it to where you want to go. The total length is shown in the side bar.
All of this confuses me. If I do the overpass turbo thing, I need the ID of the relation. How do I get that information? Also this “trail” is categorized as an abandoned railway. Not a Trail per say.
If you link to the one you’re interested in (or a similar one with the same OSM tags) people might be able to be a bit more specific.
Am I right in reading that as 406km, 115.58365048736m?
Got to say that I always have trouble reading past .1 of a mm!
So I figured out out to get the relation ID. I ran it through Overpass Turbo and the result “length = 43747.836719202955”. What measurement is this in?
https://ra.osmsurround.org/ gives the distance in km, you can even search by trail name to save looking up the relation ID.