PyrouteLib

From OpenStreetMap Wiki
Jump to navigation Jump to search
Pyroute in cycle mode, avoiding big roads and giving a quiet cycle route through back-streets and cycle paths (see image description for more details)
Shown with tiles@home images in the background

This page is about running pyroute from the command-line, or using it as a library from Python programs. For the graphical interface, see Pyroute

Background info

See the original web page: http://almien.co.uk/OSM/Routing/

Download and installing it

Source code: http://svn.openstreetmap.org/applications/routing/pyroutelib2/

Installing goes very simple on Linux run the command

 svn co http://svn.openstreetmap.org/applications/routing/pyroutelib2/

An alternative repository which supports Python 3 and the new v0.6 API (using osmapi package) can be found at https://github.com/gaulinmp/pyroutelib2. Install using:

 git clone https://github.com/gaulinmp/pyroutelib2

Running the program

Simple routing

Run the command:

route.py osmfile.osm startnode endnode transportType

To get a list of nodes

Route to OSM or GPX file

To produce an OSM XML file containing the route (for loading into JOSM, or rendering using osmarender etc:

routeAsOsm.py osmfile.osm startnode endnode transportType description

To get a GPX XML file, that you can upload to your GPS:

routeAsGpx.py osmfile.osm startnode endnode transportType description

Test if an OSM file is compatible

To test if it can load an OSM file, and how long it takes:

loadOsm.py dataFile.osm transportType

Original-style pyroute

Will generate a PNG image showing all the streets, the route, and highlighting the roads and nodes that it considered routing along (good debug tool for routing algorithms)

pyroute.py dataFile.osm node1 node2