Skip to main content

ST_HAUSDORFFDISTANCE

Introduced or updated: v1.2.911

Returns the discrete Hausdorff distance between two GEOMETRY objects. This measures how far apart two geometries are by finding the greatest distance from any vertex in one object to the nearest vertex in the other.

Syntax

ST_HAUSDORFFDISTANCE(<geometry1>, <geometry2>)

Arguments

ArgumentsDescription
<geometry1>A GEOMETRY expression.
<geometry2>A GEOMETRY expression.

Return Type

Double.

Examples

SELECT ST_HAUSDORFFDISTANCE(
TO_GEOMETRY('POINT(0 0)'),
TO_GEOMETRY('POINT(0 1)')
);

┌────────┐
│ result │
├────────┤
1.0
└────────┘

SELECT ST_HAUSDORFFDISTANCE(
TO_GEOMETRY('LINESTRING(0 0, 1 0)'),
TO_GEOMETRY('LINESTRING(0 1, 1 1)')
);

┌────────┐
│ result │
├────────┤
1.0
└────────┘

SELECT ST_HAUSDORFFDISTANCE(
TO_GEOMETRY('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
TO_GEOMETRY('POLYGON((2 0, 3 0, 3 1, 2 1, 2 0))')
);

┌────────┐
│ result │
├────────┤
2.0
└────────┘
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