0

I'm new to PostGIS and pgRouting and I'm using the pgr_dijkstra functionality and I need to convert the values it returns in the format lat/long, is that possible? If so, how?

1 Answer 1

1

Have you done the pgRouting workshop? You best start with it, if you're new to the topic.

In chapter 8.1 you will then see how to return a route with geometry. With a little modification you can adapt it to your needs:

SELECT seq, id1 AS node, id2 AS edge, cost, 
       ST_X(b.the_geom), ST_Y(b.the_geom), b.the_geom FROM pgr_dijkstra('
                SELECT gid AS id,
                         source::integer,
                         target::integer,
                         length::double precision AS cost
                        FROM ways',
                30, 60, false, false) a LEFT JOIN ways b ON (a.id2 = b.gid);
2
  • then is it easy to convert from geometry to lat/lang? The query I'm doing as it is, is already returning the geometry. Thanks
    – tvieira
    Oct 6, 2015 at 13:32
  • Your coordinate reference system needs to be lat/lon. This is the case if you have WGS84 for example.
    – dkastl
    Oct 6, 2015 at 19:07

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.