0

I have implemented pgRouting workshop and it's working fine. I need to get every edges length in kilometers to do some calculations I studied the ways table. It contains a length attribute, but it seems to be not what I exactly need.

Is there any place or way to get the length of each and every edge in kilometers or meters.

1

You can use the geometry column and the PostGIS function ST_Length_Spheroid to calculate the length of the linestring in (kilo)meters:

SELECT ST_Length_Spheroid( the_geom, 'SPHEROID["GRS_1980",6378137,298.257222101]' ) / 1000 AS km FROM ways;

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.