Today I played around with OpenStreetMap to get all geo locations for the stops of the cologne train and bus system. I needed those as preparation for the Advance Hackathon in April. To my surprise it was relatively easy to get those out of OSM.
If you want to grap some datapoints from OSM, you just have to follow these steps:
- Download the map data you need from Cloudmade or Geofabrik.
- Download osmosis
- Filter the needed data with osmosis.
To get the cologne train stops you need to start osmosis like this:
osmosis --read-xml nordrhein-westfalen.osm --bb left=6.7481 right=7.1322 top=51.8251 bottom=50.7633 --tf accept-nodes railway=tram_stop,station,halt --tf reject-ways --tf reject-relations --write-xml trainstop.osm
The bus stops can be collected like this:
osmosis --read-xml nordrhein-westfalen.osm --bb left=6.7481 right=7.1322 top=51.8251 bottom=50.7633 --tf accept-nodes highway=bus_stop --tf reject-ways --tf reject-relations --write-xml busstop.osm
After a little data parsing session I got the result I needed. All locations for all stops and their KVB-ID. You can use the KVB-ID on the KVB-Website to see detailed informations of that station. The URL for those look like this:
http://www.kvb-koeln.de/german/hst/overview/KVB-ID/
The data can be found in this git repo.