sqlitegisdistancespatialite

What unit does Spatialite's Distance() function return?


Spatialite has a the ability to calculate the distance between 2 geometries with it's Distance() function. There are other functions that work on LINESTRINGs. However I can't find out what units it returns it in. Is it metres? If I have 2 points, how do I calculate the distance between them in a spatialite query?

(For the record I'm using SRID 4326, i.e. WSG 86, i.e. the old traditional degrees of latitude and longitude).


Solution

  • the unit returned by ST_Distance(), ST_Length() and ST_Area() exactly is the one defined by the corresponding SRID.

    consequently, if you are using latitude and longitude (SRID=4326, WGS 84), any length will be measured in DEGREES, and any area in SQUARE DEGREES.

    if you are interested in giving a more conventional unit (METERS, SQUARE METERS), you simply have to project your geometries into some appropriate 'planar' CRS (e.g. UTM) using ST_Transform()