Naptan to GPX Waypoints (OSM)

If anyone has been following the goings on of OpenStreetMap of the uk you may have noticed the appearance of a load of Bus Stops (or duplicate bus stops if they where already in OSM). These have come from a database called NaPTAN kindly supplied to OSM by the UK Department for Transport and Traveline. See the OSM Wiki for more details.

These new points now need confirming/merging. I’ve also got a new GPS (BGT-31) which can alert me when I get near a waypoint – so I though why not load up the new data as waypoints into my GPS?

Heres the rough script I’ve written to download the data and convert it to the right format for my GPS. It also delete the name field, and changes the local_ref field to be the name, dropping the prefix 450. This is because the GPS only shows 6 characters for the name of a waypoint and in my area the last 6 characters are probably the easiest way to identify individual bus stops in 6 characters.

wget[naptan:verified][bbox=-......] -O /tmp/naptan.osm
xmlstarlet ed -d "//tag[@k='name']" < naptan.osm | xmlstarlet ed -u "//tag[@k='local_ref']/@k" -v 'name' > naptan2.osm
sed 's/450//' < naptan2.osm > naptan.osm
gpsbabel -i osm -f naptan.osm -o ozi -F naptan.wpt

Just change the bbox to the area you want and it will generate the waypoint file which can then be uploaded to the GPS. It is a but rushed but it does the job.

September 27, 2009 · robert · Comments Closed
Tags: , , ,  · Posted in: OSM