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

while working with POSTGIS pgrouting, for calculateing the distance between two roads(lines) i got the shortest_path function.

But the logic is based on Start_point(Start_id) and end_point(end_id) but in my data the linestring contains so many internal points like ('linestring(1 1,2 2,3 3,4 4,5 5)' just for example..)

it is taking start point (1 1) endpoint(5 5)

if other line starting with (5 5) it is showing as ('linestring(5 5,6 6)')

But line which crossing the point inside the linestring like(2 2,3 3,4 4) which is not telling as connected.. example

table roads: id name way 1 A linestring(1 1,2 2,3 3,4 4,5 5) 2 B linestring(5 5,6 6) 3 c linestring(2 1,2 2,2 3)

if i am applying shortest_path function from point(1 1) to (6 6) its showing the way but for (1 1) to (2 3) it is not showing anything...but there is a route for this (1 1,2 2,2 3)

can anyone please help me out for finding the solution..

Regards Deepak M

share|improve this question
up vote 2 down vote accepted

PgRouting shortestPath() runs the Dijkstra algorithm and finds the shorted route between two nodes.

To do that, pgRouting needs a routable network. What you described above doesn't sound like a routable network. It seems to be just an ordinary table of intersecting linestrings. This raw data has to be preprocessed into a structure of nodes and edges (connections between nodes). Every intersection has to be represented as a node. Without nodes there is no connectivity within the network.

share|improve this answer
hi underdark, means i need to convert my table in to routable by DE-NORMALIZING IT? i.e linestring(1 1, 2 2, 3 3) to be converted to linestring(1 1,2 2) and linestring(2 2,3 3)? – Deepak M Aug 13 '12 at 12:09
No, but you need to split edges at every intersection. – underdark Aug 13 '12 at 16:36

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.