PostGISMeasurement

ST_MinimumClearance

What is ST_MinimumClearance?

ST_MinimumClearance returns the minimum clearance of a geometry — the smallest distance by which a vertex can be moved without introducing a topological error (an intersection or loss of simplicity). It is a measure of geometric robustness: a low clearance means the geometry is close to being invalid.

SQL
ST_MinimumClearance(geometry g)float

If a geometry has no "fragile" features (for example a single point), the function returns infinity. Otherwise it returns a distance in CRS units.

When would you use ST_MinimumClearance?

Use ST_MinimumClearance in QA and data-cleaning workflows to identify geometries likely to fail under precision loss — rounding to a lower-precision grid, conversion to single-precision floats, or export to a format with limited coordinate precision. It is also useful for setting a safe gridSize before calling ST_SnapToGrid or performing robust overlays.

SQL
1-- Flag geometries vulnerable to rounding below 1 cm
2SELECT id, ST_MinimumClearance(geom) AS clearance_m
3FROM parcels
4WHERE ST_MinimumClearance(geom) < 0.01;

FAQs

What does "clearance" mean exactly?

It is the smallest distance such that perturbing a single vertex by that amount could break the geometry's validity — for example causing a polygon ring to self-intersect. Larger values mean the geometry tolerates more rounding.

What units does it return?

The CRS units of the input — degrees for EPSG:4326, metres for most projected CRSs. There is no geography overload.

What does it mean if the result is `infinity`?

The geometry has no features whose proximity could cause invalidity — typically a single point or a geometry so "loose" that any reasonable perturbation remains valid.

How do I visualise the clearance violation?

Use ST_MinimumClearanceLine, which returns a two-point LINESTRING between the vertex and the nearest segment it could collapse into — useful for highlighting the problem in a map review.