ST_MinimumClearance — Returns the minimum clearance of a geometry, a measure of a geometry's robustness.
float ST_MinimumClearance(
geometry g)
;
It is possible for a geometry to meet the criteria for validity according to ST_IsValid (polygons) or ST_IsSimple (lines), but to become invalid if one of its vertices is moved by a small distance. This can happen due to loss of precision during conversion to text formats (such as WKT, KML, GML, GeoJSON), or binary formats that do not use double-precision floating point coordinates (e.g. MapInfo TAB).
The minimum clearance is a quantitative measure of a geometry's robustness to change in coordinate precision. It is the largest distance by which vertices of the geometry can be moved without creating an invalid geometry. Larger values of minimum clearance indicate greater robustness.
If a geometry has a minimum clearance of e
, then:
No two distinct vertices in the geometry are closer than the distance e
.
No vertex is closer than e
to a line segment of which it is not an endpoint.
If no minimum clearance exists for a geometry (e.g. a single point, or a MultiPoint whose points are identical),
the return value is Infinity
.
To avoid validity issues caused by precision loss, ST_ReducePrecision can reduce coordinate precision while ensuring that polygonal geometry remains valid.
Availability: 2.3.0
SELECT ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))'); st_minimumclearance --------------------- 0.00032