1

I'm trying to find a shortest path between 2 nodes using djikstra method but it keeps saying

ERROR: Error, query must return columns 'id', 'source', 'target' and 'cost'

this is my query:

SELECT seq, id1 AS node, id2 AS edge, cost
FROM pgr_dijkstra('SELECT gid, source,target, ST_Length(geom2d) as cost FROM  public.canada_rail_net', 1, 200, false, false);

is there anything wrong with column names?

0

I think it's your gid

Do

   SELECT seq, id1 AS node, id2 AS edge, cost
       FROM pgr_dijkstra('SELECT gid As id, source,target, ST_Length(geom2d) as cost 
         FROM  public.canada_rail_net', 1, 200, false, false);
|improve this answer|||||
  • If you are not sure about your answer, write a comment rather than an answer with few words. Please edit your answer or post it as a comment. – Farid Cheraghi Jun 20 '15 at 18:50
  • well it fixed my problem :) – Hirad Roshandel Jun 20 '15 at 19:56
  • okay I've updated so it's a complete sql statement :) – LR1234567 Jun 23 '15 at 19:38

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.