1

I am having a problem with pgr_dijkstra algorithm not finding some of the node vertices in my table. I have a large dataset of survey travel diaries and am trying to determine their shortest paths between each place they visit. I linked each place visited to the closest node in my OSM network using the ways_vertices_pgr table. I can find the nodes that are returning a blank shortest route in either the source or target column of the ways table (my edge table) but for some reason pgr_dijkstra is not finding the node when I call the function for about half of my routes.

Do I need to do something to tell the algorithm to look in both source and target columns of the ways table?

Here is my query that fills in the routes, which worked for about half of my routes. I should mention that the prg_dijkstra function I use here is the prg_dijkstra wrapper function given on the workshop website on the pgrouting homepage. I have tried with the full function as well and it doesn't seem to make a difference. I have also done pgr_analyzegraph and the network topology returns OK.

update analysis.routing
set
routeline2 = (select st_multi(st_union(pgr.geom)) from (select * from 
pgr_dijkstra('ways',analysis.routing.source,analysis.routing.target)) as pgr) ; 

Do I need to do ST_Reverse or some other transformation to get the function to find the node?

1

In case you have the ways_vertices_pgr and can't find your node ID there something must be wrong with your data.

But you can't assume that a node ID will be found in both source and target column. It could be in both but only needs to appear in one of them. So whey you're looking for a node ID you need to search in both columns.

If you have lots of node ID's, which are only available in one column, then it looks like you have many dead-end roads. If this appears to different in reality, then your road network is eventually not well connected.

  • The node ID is in the ways_vertices_pgr table, and I use that table to find the closest node to the point layer from my survey. So, my nodes are in the vertices table and can also be found in the ways table. I don't believe I have a lot of dead end roads, the OSM extract I use is for the Denver-Boulder metro area. So I guess I don't understand why it is returning a NULL route? I have verified in QGIS that the node can be found on a map and is in fact not a dead end road. Any other suggestions on troubleshooting? – EconGeo Jun 17 '14 at 8:28
0
pgr_dijkstra('ways', analysis.routing.source, analysis.routing.target) 

Check in the documentation correct usage of the function:

pgr_costResult[] pgr_dijkstra(text sql, integer source, integer target,
                       boolean directed, boolean has_rcost);
  • 1
    can you post how to find the documentation? – Brad Nesom Mar 25 '15 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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