Name

ST_HausdorffDistance — Returns an approximation to the Hausdorff distance between two geometries. It offers a measure of dissimilarity between the geometries.

Synopsis

double ST_HausdorffDistance(bytea GeomA, bytea GeomB);

double ST_HausdorffDistance(bytea GeomA, bytea GeomB, double densityFrac);

Alias

HausdorffDistance

Description

This algorithm computes the Hausdorff distance restricted to discrete points for one of the geometries. It is an approximation to the Hausdorff Distance based on a discretization of the input Geometry.

The points can be either the vertices of the geometries, or the geometries with line segments densified by a given fraction (if the parameter densityFrac is specified).

[Note]

Fraction must be in range (0.0 - 1.0)

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

SELECT ST_HausdorffDistance( 
	ST_GeomFromText('POLYGON ((1.4 1, 2 4, 4 4, 3 1, 1.4 1))'),
	GeomFromText('POLYGON ((1 1, 2 4, 4 4, 3 2, 1 1))'));
--Result
0.8944271909999159

SELECT ST_HausdorffDistance( 
	ST_GeomFromText('POLYGON ((1.5 1.3, 2 3, 4 3, 3 1.3, 1.5 1.3))'),
	GeomFromText('POLYGON ((1 1.5, 2 5, 4 3, 3 1.6, 1 1.5))'),0.5);
--Result
2.0
ST_HausdorffDistance( A, B) = 0.8944
ST_HausdorffDistance( A, B, 0.5 ) = 2

Related functions

ST_Distance, ST_Equals