Appearance
ST_DISTANCE
Returns the minimum geodesic distance between two GEOGRAPHY objects in meters.
By default, the calculation is performed on the spheroid defined by the SRID. If use_spheroid is set to FALSE, a faster spherical calculation is used instead.
See also:
Syntax
sql
ST_DISTANCE(<a>, <b>, <use_spheroid> = true)Arguments
<a>and<b>: The twoGEOGRAPHYobjects to measure the distance between<use_spheroid>: An optional boolean to control the calculation mode:TRUE(default): Uses the spheroidal model for higher precisionFALSE: Uses the spherical model for faster computation
Returns
Returns a FLOAT8 value representing the distance in meters between the two GEOGRAPHY objects. Returns NULL if the calculation is not possible.
Example
sql
SELECT ST_Distance('POINT(0 0)'::GEOGRAPHY, 'POINT(1 1)'::GEOGRAPHY);
-- 156899.56829134
SELECT ST_Distance('POINT(0 0)'::GEOGRAPHY, 'POINT(1 1)'::GEOGRAPHY, false);
-- 157249.597768505