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 am trying to use pgrouting's shortestpath function. It returns a set of edges for the shortest path. However, the start node of the next edge is not the end node of the previous edge. I mean they are not connected. So while displaying I am joining the end node of the first edge to the start node of the next edge.

However, I am seeing that the coordinates are repeating. I am not sure why, For eg plotting just the coordinates of the start and end node of each edge, I have something like this:

start end
A     B 
C     D
A     E

As you can see the coordinates are repeating like A,A in the previous case. As a result there are lots of lines crossing over.

Any suggestions or clarifications?

share|improve this question

Better you post your query as well to see what you're trying to do.

The reason might be that the query returns the list of edges in the way they are stored in the database. And they are stored in the database as they have been digitized/imported. So what is the start of an edge and what is the end depends on how they were created.

If not only the geometry but also the start end end order of the route is important for you, you need to check this as an additional step.

Possibility 2 (reading your post once more):

If your result is even more weird, then probably your network topology is wrong. How did you get source and target ID columns?

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.