Monday 20 February 2017

postgis - What is the unit used in ST_Distance()?


I wonder what the unit is of the float being returned from ST_Distance.


In the documentation it says:



...cartesian minimum distance (based on spatial ref) between two geometries in projected units.



What are these projected units?


The geometry is stored in a field: geometry(Point,4326).



Answer




I think this is the most frequent question on PostGIS list over time :-)


If your data is in SRID 4326 and you use geometry type the result will not give any meaning. It is in degrees.


To get the result in meters just cast to geography type and ST_Distance will calculate the distance along the great circle instead and return in meters.


geometry(Point,4326)::geography

Another option is to project your data to some local projection based on a suitable unit. Then the answer will be in that unit.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...