I am using PostgeSQL 9.5 and pgRouting 2.1.0. I am trying to test pgRouting tool in my postgres DB by following this tutorial pgRouting 2.0 for Quick Windows Guide. Although the tutorial assumes road transport network data of Vienna in GEOJSON format but due to unavailability of data at mentioned link, I used my own data and converted the ESRI shapefile (16,060 rows) to GEOJSON using QGIS. Then, I used QGIS DB Manager to import street.geojson file to my postgres "routing" DB. As per tutorial, I used following commands to add "source" and "target" columns as well as to create topology.

alter table public.street add column source integer;
alter table public.street add column target integer;
select pgr_createTopology('public.street', 0.0001, 'geom', 'id');

However, when I used following set of commands to test pgr_dijkstra algorithm:

SELECT seq, id1 AS node, id2 AS edge, cost, geom
FROM pgr_dijkstra(
  'SELECT id, source, target, st_length(geom) as cost FROM public.street',
  1, 3000, false, false
  ) as di
JOIN public.street pt
ON di.id2 = pt.id;

the query runs successfully but I am not getting any output.

Output Screenshot

Can anyone help me to understand what's wrong with my processing?


After running the query to identify the records, the results are as under:

Query Results

  • Do those nodes exist (1 and 3000) in your street table?
    – Regina Obe
    Commented Aug 1, 2016 at 15:36
  • @LR1234567: I used pgr_createTopology() function and it processed all 16,000+ edges. I hope your query is related to this. I can see source and target column values for all 16,060 rows when I view the data in street table in postgres.
    – khajlk
    Commented Aug 1, 2016 at 15:43

1 Answer 1


You must pass in the ID of the src and dest records.

Run this statement to help you identify the records you are looking for:

SELECT id, source, target
FROM public.street
WHERE (id = 1 or id = 3000)
    or (src = 1 or src = 3000)
    or (dest = 1 or dest = 3000);

You passed id=1 for src and id=3000 for dest into pgr_Dijkstra. The records it is using are row 2 for src (with a source=31) and row 4 as dest (with a target=5460).

If you are wanting row 1 and row 7 then you need to pass id=1386 as src (with source=1) and id=10392 as dest (with target=3000).

  • Okay, after running this query I am able to see three columns of ids source and targets. Can you please be specific how does it help to resolve the above problem? Since I used my own data, this could be a problem but above code worked already on the page I mentioned.
    – khajlk
    Commented Aug 1, 2016 at 17:38
  • @JibranKhan can you display the results please? Edit your question and add the screenshot.
    – kttii
    Commented Aug 1, 2016 at 18:05
  • I have edited the question and results have been added as a screen shot! Thank you for your help.
    – khajlk
    Commented Aug 1, 2016 at 18:33
  • 1
    @JibranKhan You passed 1 for src and 3000 for dest into pgr_Dijkstra. The records it is using are row 2 for src and row 4 as dest. If you are wanting row 1 and row 7 then you need to pass 1386 as src and 10392 as dest.
    – kttii
    Commented Aug 1, 2016 at 18:58
  • You are right. I passed wrong records for source and target. I am getting output at least after passing correct values. But, I am not getting cost and other values for all rows like the one shown at tutorial link. The problem looks like my data is not noded!
    – khajlk
    Commented Aug 1, 2016 at 19:58

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.