I recently started to work with pgRouting with this osm file

So I used osm2pgRouting to parse the file and load it into the DB.

osm2pgRouting (using the mapconfig_for_pedestrian.xml) work's fine, but when I try to do a Dijkstra all I get is the Empty set.

here is the SQL request I'm using:

    pgr_dijkstra ('SELECT id, source, target, cost, reverse_cost FROM ways',

here my environment:

postgres (PostgreSQL) 10.11
pgRouting: 3.0.0 beta
osm2pgrouting Version 2.3.7

can someone give me a direction on what could be the cause of this behaviour?

more information on the exact line I believe I'm using.

|   id | source | target |
| 5    |   3317 |      4 |
| 3312 |      3 |   3780 | 
  • Possible reason for this could be the source(10) and target(11) value you are specifying. They might be the source and target of the same line. When you give a source id (10). It gets that line and selects its target(11) value to find the next line which has that id a source. But in your case your target itself is that line. So the output is null. Try selecting from your table where source = 10. You will find target value of that line is 11.
    – Arun
    Feb 1, 2020 at 10:05
  • turn out that source 10 does not exist but the problem persists with other sources and targets I tried with source 3 (as a target of 3780) and target 4 (has the source of 3317) and I'm still getting an empty set.
    – julia
    Feb 6, 2020 at 9:05
  • 3780 is the id of line segement or its the target column value??
    – Arun
    Feb 7, 2020 at 5:08
  • i edited the question to have more info on the rows.
    – julia
    Feb 7, 2020 at 9:33
  • Possibly then there is no route between your 3(source) and 4(target). If you are sure that there must be route between this two ids. You can try one solution. Create a copy of your data. Now clear your source and target column. And run pgr_createTopology function of pg_routing. This will recalculate the source and target value for your network. And then get the source of id=5 and target of id=3312 and run your pgr_dijkstra with the new source and target value
    – Arun
    Feb 7, 2020 at 12:24

1 Answer 1


It is the issue with the OSM data. It is not noded properly. So that's why we have issue in generating route out of pg_routing. Work around is to create noded network. You can use pg_routing function pgr_nodeNetwork.

SELECT pgr_nodeNetwork('route', 0.001, id := 'gid', the_geom:='geom');

It will create a new dataset which will have node at every intersection. And you can use this data set for routing purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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