Monday, February 19, 2007

Find shortest distance path postgis postgres linedata

You could consider using pgRouting ( .

This extension to Postgres/PostGIS needs some topology and topology support for PostGIS is still in its infancy and barely documented… L

Now to implement ‘topology’ the *easy* way… ;-)

Use OpenJump! (

There’s a tool there called ‘Planar Graph’…

You can use it to get every line segment documented (start and end nodes for each line).

Add a ‘length’ field to your dataset.

OpenJump also has a tool to calculate areas and lengths… ;-)

Save your dataset from OpenJump into PostGIS.

The ‘length’ field acts as an initial cost for turning….

Then use the shortest_path() function from pgRouting and you’re on your way!

Also heard from the developers of pgRouting that support for turn restrictions is somewhere in the near future… ;-)

(OJ PeopleĆ  I’m posting this to the list as I think it’s useful ;-) )


Pedro Doria Meunier

1 comment:

meme said...

Hi, Your comment is very helpful! I have only a marginal problem: which is the map that I have to save as PotsGIS table of the ones generated by defining the planar graph? when i execute the shortest path by pbrouting I cannot see any origin point or destination point.. I guess I am saving the wrong map :-s Could you please help me?! Thanks a lot,