- hausdorff_distance(a, b, densify=None, **kwargs)#
Compute the discrete Hausdorff distance between two geometries.
The Hausdorff distance is a measure of similarity: it is the greatest distance between any point in A and the closest point in B. The discrete distance is an approximation of this metric: only vertices are considered. The parameter ‘densify’ makes this approximation less coarse by splitting the line segments between vertices before computing the distance.
- a, bGeometry or array_like
- densifyfloat or array_like, optional
The value of densify is required to be between 0 and 1.
See NumPy ufunc docs for other keyword arguments.
>>> from shapely import LineString >>> line1 = LineString([(130, 0), (0, 0), (0, 150)]) >>> line2 = LineString([(10, 10), (10, 150), (130, 10)]) >>> hausdorff_distance(line1, line2) 14.14... >>> hausdorff_distance(line1, line2, densify=0.5) 70.0 >>> hausdorff_distance(line1, LineString()) nan >>> hausdorff_distance(line1, None) nan