[GIS] PostGIS pgr_dijkstra function not finding node that appears in ways table

osm2pgroutingpgroutingpostgis

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?

Best Answer

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.

Related Question