ST_DistanceSpheroid¶
Introduction: Return the geodesic distance of A using WGS84 spheroid. Unit is meter. Compared to ST_Distance + ST_Transform, it works better for datasets that cover large regions such as continents or the entire planet. It is equivalent to PostGIS ST_Distance(geography, use_spheroid=true) and ST_DistanceSpheroid function and produces nearly identical results. It provides slower but more accurate result compared to ST_DistanceSphere.
Geometry must be in EPSG:4326 (WGS84) projection and must be in lat/lon order. You can use ST_FlipCoordinates to swap lat and lon. For non-point data, we first take the centroids of both geometries and then compute the distance.
Format: ST_DistanceSpheroid (A:geometry)
SQL example:
SELECT ST_DistanceSpheroid(ST_GeomFromWKT('POINT (51.3168 -0.56)'), ST_GeomFromWKT('POINT (55.9533 -3.1883)'))
Output: 544430.9411996207