ST_MinimumClearanceLine
What is ST_MinimumClearanceLine?
ST_MinimumClearanceLine returns a two-point LINESTRING whose length is the geometry's minimum clearance — the smallest distance by which a vertex can be moved before the geometry becomes invalid. It is the visual companion to ST_MinimumClearance.
ST_MinimumClearanceLine(geometry g) → geometryReturns an empty LINESTRING if the geometry has no finite clearance (for example a single point).
When would you use ST_MinimumClearanceLine?
Use ST_MinimumClearanceLine in QA and map review to highlight the exact spot where a geometry is fragile — the vertex and segment pair that could collapse under precision loss. It is useful when preparing data for export to formats with limited coordinate precision, when snapping to a grid, or when triaging polygons that fail validation.
1-- Visualise the most vulnerable spot in each parcel
2SELECT id, ST_AsText(ST_MinimumClearanceLine(geom)) AS clearance_line
3FROM parcels
4ORDER BY ST_MinimumClearance(geom) ASC
5LIMIT 20;FAQs
What does the returned line represent?
Its two endpoints are the vertex and the nearest point on another segment that together define the geometry's weakest tolerance. Moving that vertex onto the opposite endpoint would break the geometry.
What units are the line's coordinates in?
The same CRS as the input. The line's length (in CRS units) equals ST_MinimumClearance(geom).
Is this the same as ST_ShortestLine(geom, geom)?
No. ST_ShortestLine on a single geometry returns a zero-length line on the geometry itself. ST_MinimumClearanceLine identifies the vertex-to-segment pair that governs the geometry's topological robustness.
What does it return for a simple POINT?
An empty LINESTRING, because a single point has infinite clearance — no vertex-segment pair exists.