This topic describes the ST_DistanceSpheroid function. This function calculates the minimum distance between two geometry objects that are represented by latitudes and longitudes on an ellipsoid. The minimum distance is measured in meters.
Syntax
float ST_DistanceSpheroid(geometry geomlonlatA , geometry geomlonlatB , spheroid measurementSpheroid);Parameters
| Parameter | Description |
|---|---|
| geomlonlatA | The first geometry object that you want to specify. |
| geomlonlatB | The second geometry object that you want to specify. |
| measurementSpheroid | The ellipsoid that you want to define. |
Description
This function does not check the spatial reference identifier (SRID) of a geometry object. This function always assumes that a geometry object is represented in the coordinates of the ellipsoid that you define.
Examples
Calculate the minimum distance between two geometry objects by using the default parameter
settings.
SELECT ST_DistanceSpheroid(ST_GeomFromText('POINT (120 36)',4326), ST_GeomFromText('POINT (116 40)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]');
st_distancespheroid
---------------------
566034.793071762
(1 row)