Easily import OpenStreetMap? data into a pgRouting database using osm2pgrouting tool.

osm2pgrouting was primarily written by Daniel Wendt and is now hosted on the pgRouting project site.

osm2pgrouting Features

  • Uses XML configuration file to select road types and classes to import
  • Creates types and classes tables, which can help to create sophisticated cost functions


If you already installed pgRouting, you should have all required libraries/packages.

  • PostgreSQL
  • PostGIS
  • pgRouting

Currently osm2pgrouting is only tested on Linux distributions.

How to install osm2pgrouting

Get the latest version from SVN:

svn checkout osm2pgrouting

Then compile it:


If you get an error like

src/Export2DB.h:25:22: error: libpq-fe.h: Datei oder Verzeichnis nicht gefunden

src/Export2DB.h:84: error: ISO C++ forbids declaration of ‘PGconn’ with no type

src/Export2DB.h:84: error: expected ‘;’ before ‘*’ token

src/Export2DB.cpp: In constructor ‘Export2DB::Export2DB(std::string,

std::string, std::string, std::string, std::string)’: 

....etc etc.

just change src/Export2DB.h and set the path to libpq-fe.h statically.

How to use osm2pgrouting

Start the program like this:

./osm2pgrouting -file your-OSM-XML-File.osm -conf mapconfig.xml -dbname routing -user postgres -clean

all available parameters are:

-file <file>  -- name of your osm xml file
-dbname <dbname> -- name of your database
-user <user> -- name of the user, which have write access to the database
-conf <file> -- name of your configuration xml file
-host <host>  -- host of your postgresql database (default:
-port <port> -- port of your database (default: 5432)
-passwd <passwd> --  password for database access
-clean -- drop peviously created tables

More information