NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'd like to be able to plot routes between rail stations (non-commuter, primarily transportation lines). However, I don't understand enough about the OpenStreetMap stack to know where to begin. I've read that the rail lines are stored as GPX data, and that it's available in raw format to those who wish to do something with them. So my questions are:

1.) Is it currently possible to route between rail stations on rail lines in OpenStreetMap without third party tools (I assume this is not the case). 2.) Is the rail line data available as GPX data, and if not, what format? 3.) Is there a well known or generally accepted way to route between rail stations, or is there a third party tool that uses/integrates with OpenStreetMap?


asked 31 May '13, 16:57

sparticus's gravatar image

accept rate: 0%

You could try creating a "railway" config for one of the existing osm routing engine like OSRM, but that doesn't deal with the train schedules, wether they're direct or omnibus, etc. If you use the train schedule data (which isn't something provided by OSM), you'd probably need an approach quite different from a routing engine.

permanent link

answered 31 May '13, 17:29

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
accept rate: 19%

The OP's request for "non-commuter, primarily transportation lines" suggests that he's less interested in schedules, however.

(02 Jun '13, 08:54) Richard ♦

OSM data is usually not in GPX format but in a own XML format. You can downloaded OSM data in various ways. It is also possible to download smaller extracts or only specific data using for example the Overpass API. In your case you are interested in elements with railroad related tags, especially the railway key. For routing there a several online and offline routers available. You will have to modify them if you want to route on railways.

permanent link

answered 31 May '13, 19:10

scai's gravatar image

scai ♦
accept rate: 23%


While quite a hack, it is possible to get by without modifying the routing engine - by modifying the data. Get an extract of all railway lines, and re-write the tags so that they look like roads, then feed them to a router.

(01 Jun '13, 23:41) Frederik Ramm ♦

... with an extra turn restriction at every set of points (switches) I suspect :-)

(03 Jun '13, 17:18) Andy Allan

To be honest, if you're using OSRM, it's easier to modify the routing engine - by supplying a new lua profile - than to hack the data. OSRM actively encourages you to do that. Andy's point about turn restrictions can be trivially achieved by modifying the turn_function to return very high penalties for turns over (say) 45°.

(03 Jun '13, 21:43) Richard ♦

If you for instance look for tram line "1" in Vienna, you could get all the objects necessary to draw it via this overpass query.

Is this what you are looking for?


permanent link

answered 04 Jun '13, 14:08

_al's gravatar image

accept rate: 4%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 31 May '13, 16:57

question was seen: 6,955 times

last updated: 04 Jun '13, 14:08

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum