Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

A little background:

I've got PostGIS 2.0 and all the TIGER2010 data loaded for a U.S. State California.

I've got a table with points stored as data type geometry. I've learned enough to get the distance "as the crow flies" between two of the points and my samples are satisfactory when comparing them with Google Earth.

Now, I'd like to generate distance via a street/highway route. The requirements on the route are that it be the shortest. I only need shortest travel distance as a numeric value. No pretty maps.

-I've got every TIGER 2010 shape files loaded for California in PostGIS 2.0. I'm such a newbie it's not clear to me if this is sufficient data for calculating a route using PgRouting. Is it?

-If TIGER 2010 data is sufficient, does it need to be prepared somehow for a shortest_distance query?

If there's a useful how-to somewhere, then please send that along as a reply.

As a total newbie, I didn't know that the roads data is already loaded in the 'edges' table. Thanks to the commenter below for pointing it out!

Now, follow the instructions here: http://underdark.wordpress.com/2011/02/07/a-beginners-guide-to-pgrouting/

That should satisfy the 'lines layer' requirement Fabien is referring to.

share|improve this question
Have you gone through the online tutorials and workshops? –  dassouki Jul 28 '11 at 1:22
underdark.wordpress.com/2011/02/07/… No mention of TIGER2010 data. The workshop at pgrouting.org has no mention of TIGER2010 data. Furthermore, the workshop at pgrouting.org suggests my latitude/longitude points might not be the right format for a shortest_route query. –  juheesus Jul 28 '11 at 1:26
Lat/lon data are suboptimal if you want to perform distance calculations because they won't give as accurate results as if you had chosen a fitting projected coordinate system. If TIGER2010 data already contains road length measurements you can use those as a cost attribute and not worry about the projection (at least for Dijkstra). –  underdark Jul 28 '11 at 7:32

1 Answer 1

All you need if you want to run the shortest path (Dirkjtra algorithm) is a basic set if colomns listed in this workshop :


You need only one polylines or lines layer. The function assign vertex creates the topology.

source and target are the identifier for the first and last node of each geometry. It is used to build the topology. You have to use the funciton assign_vertex in the link above.

Then you need a colomn that is your cost. Again all explained the document above. All the algorithm except the shooting star crash if cost are negative.

You can use the reverse_cost is you want a cost from source to target and a different cost from target to node.

Algorithms A* and Dirkjtra are from node to node. The example of queries are in the link above. Shooting * goes from segment to segment. Shooting * accepts cost that are negative as a way to prevent one way of a segment to be used.

A* need additionnal fields compared to Dirkjtra, becauses it uses heuristics relying on geography. Shooting * requires even more field, for it can implements turn restrictions. Go through the document.

This website also register other tutos that are not official. http://ebmgh.com/blog/2009/12/computing-directions-with-pgrouting/

Take it step by step, READ the documentation and for Dirkjtra and A* there is no real difficulty.

Good luck. As for the data, if you can build a topology, you're good to go.

share|improve this answer
Thanks for everyone's assistance. Based on the information provided, I think I need to import the TIGER2010 roads files using ogr2ogr to my PostGis database. –  juheesus Jul 28 '11 at 18:37
Have you already added pgRouting functionality to your database? –  underdark Jul 28 '11 at 19:41
The pgRouting functionality is in. –  juheesus Jul 29 '11 at 18:54

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.