Skip to main content
Returns the vertex-only (discrete) Hausdorff distance between the given 2 geometries. Both geometries are treated purely as sets of vertices: for every vertex of one geometry the distance to the nearest vertex of the other geometry is computed, and the function returns the largest such distance found in either direction. This differs from ST_HausdorffDistance, which measures each vertex against the other geometry’s segments and can optionally densify those segments. Because segment interiors are ignored here, ST_HausdorffDistanceVertices is never smaller than ST_HausdorffDistance(g1, g2), the overload without a densityFraction. It takes no densityFraction parameter itself. If either geometry is empty, null is returned.
That bound does not extend to the densified overload. Densification adds sampled points along the segments, and those samples can be farther from the other geometry than any of its vertices are, so ST_HausdorffDistance(g1, g2, densityFrac) may return a larger value. For example, LINESTRING (0 0, 10 0) and MULTIPOINT ((0 1), (10 1)) give 1.0 from ST_HausdorffDistanceVertices but sqrt(26) (5.0990195135927845) from ST_HausdorffDistance(..., 0.5), which samples the line’s midpoint.
Even though the function accepts 3D geometry, the z ordinate is ignored and the computed distance is equivalent to the geometries not having the z ordinate.
ST_HausdorffDistanceVertices

Signatures

Parameters

Geometry
required
The g1 value.
Geometry
required
The g2 value.

Return type

A numeric value.

Examples

The vertices of the second line sit 1 and 2 units above the first line, but their nearest vertex is an endpoint of that line, so the result is sqrt(29) rather than the segment-based sqrt(26):