Skip to main content

ST_DISTANCE

Introduced or updated: v1.2.555

Returns the minimum Euclidean distance between two GEOMETRY objects.

Syntax

ST_DISTANCE(<geometry1>, <geometry2>)

Arguments

ArgumentsDescription
<geometry1>The argument must be an expression of type GEOMETRY and must contain a Point.
<geometry2>The argument must be an expression of type GEOMETRY and must contain a Point.
note
  • Returns NULL if one or more input points are NULL.
  • The function reports an error if the two input GEOMETRY objects have different SRIDs.

Return Type

Double.

Examples

SELECT
ST_DISTANCE(
TO_GEOMETRY('POINT(0 0)'),
TO_GEOMETRY('POINT(1 1)')
) AS distance

┌─────────────┐
│ distance │
├─────────────┤
1.414213562
└─────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today