ST_Distance

Determine the minimum distance between two points or segments.

SRID support.

Syntax

ST_Distance(geo1, geo2[, unit[, cSys[, intersectTest]]]);
geo1
The first input point or segment.

Type: VARCHAR(ANY)

geo2
The second input point or segment.

Type: VARCHAR(ANY)

unit
The units of the distance. Possible values include 'meter', 'kilometer', 'foot', 'mile', and 'nautical mile'.

Type: VARCHAR(ANY)

Default: 'meter'

cSys
The coordinate system of the input geometry.

Type: VARCHAR(ANY)

Default: The coordinate system of the input geometry's SRID or, if the input geometry has no SRID, 'WGS84'.

intersectTest
If set to TRUE, test for intersection between the input geometries and return 0 if they do. Otherwise, calculate the distance between the geometries.

Type: BOOL

Default: TRUE

Returns

A value of type DOUBLE indicating the minimum distance between two the two input points or segments.

Examples

SELECT inza..ST_Distance(inza..ST_Point(0, 0, 1234), inza..ST_Point(1, 0, 1234));

ST_DISTANCE
-----------
1
(1 row)
SELECT inza..ST_Distance(inza..ST_Point(0, 0, 1234), inza..ST_Point(1, 0, 1234), 'foot');

ST_DISTANCE
-----------
3.2808398950131
(1 row)
SELECT inza..ST_Distance(inza..ST_Point(0, 0, 1234), inza..ST_Point(1, 0, 1234), 'meter', 'wgs84');

ST_DISTANCE
-----------
111319.49079323
(1 row)