PostGIS

ST_MinimumClearance

Prev

7.12. Measurement Functions

Next

Name

ST_MinimumClearance — Returns the minimum clearance of a geometry, a measure of a geometry’s robustness.

Synopsis

float +`*`+ST_MinimumClearance*(`geometry `g`)`;

Description

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 segement 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

Examples

SELECT ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))');
 st_minimumclearance
---------------------
             0.00032

See Also

Prev

Up

Next

ST_3DMaxDistance

Home

ST_MinimumClearanceLine