Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a routing application using OpenStreetMap. Currently, my task is to convert the data from an OSM file to PostgreSQL.

I read about osm2pgsql, but the problem is it says there that osm2pgsql is not suited for routing. I read about Osmosis too, but there is something about rails port, which I think means I need to learn Ruby in Rails. I tried studying RoR in the past and I found it too difficult for me to learn.

I'm using PHP for my application. How can I able to extract the data from the OSM file and export it to my PostgreSQL. I know I might be missing something here, but I'm a newbie when it comes to mapping application. I hope someone can help me. Thanks! :D

share|improve this question
@iant thanks for editing. – jalbautista Sep 7 '10 at 13:20
up vote 9 down vote accepted

Routing in Postgres / PostGIS is handled by the pgRouting library from

It looks like a script has already been written to handle osm straight into pgRouting at

You will need to install pgRouting within Postgres before running the osm2pgrouting script.

share|improve this answer
The link is now: – mattwigway Jul 28 '11 at 7:05
thanks, have edited my original answer to reflect this update. I could not find the fully worked example, so I have removed this link. – Kelso Jul 28 '11 at 23:14

Also pay your attention to osm2po ( - it could generate sql scripts compatible with pgRouting and in some cases it easier to use than osm2pgrouting (for example on MS Windows platform as osm2po is written in Java).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.