Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

The ST_length() function returns the length of a linestring but not in meters.

Is there a function like ST_Length() but in meters?.


share|improve this question

2 Answers 2

up vote 8 down vote accepted

St_Length() returns the length in the units of its Spatial Reference System. If you want to get meters, you will need to transform your feature to a different SRS that uses meters as units. This can be done on-the-fly, so don't worry about writing out another data set.

SELECT ST_AsText(ST_Transform(the_geom,26915)) from my_table;

In this example, SRID 26915 is UTM Zone 15 N, NAD83.

share|improve this answer
Or simply add your own field and manage the calculation yourself. NOTE you have to write your own trigger or recalculate it on changes in your lengths. –  Brad Nesom Oct 11 '12 at 4:12

Examples of SQL request: how-to-calculate-length-of-polyline-geometry-for-several-tables-in-postgis

SQL request (length in km (/1000 -delete for meters)):

sum(ST_Length_Spheroid(the_geom,'SPHEROID["WGS 84",6378137,298.257223563]'))/1000 AS km_roads 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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