PostGISGeometry Validation

ST_IsValidDetail

What is ST_IsValidDetail?

ST_IsValidDetail returns a valid_detail row type combining valid (boolean), reason (text), and location (geometry). It is the richest form of PostGIS validity reporting, useful for interactive debugging.

SQL
1ST_IsValidDetail(geometry geom) → valid_detail
2ST_IsValidDetail(geometry geom, integer flags) → valid_detail

flags accepts 1 for ESRI-compatible relaxed validation. The returned location points to the vertex or intersection that caused the failure, if any.

When would you use ST_IsValidDetail?

Use ST_IsValidDetail in data-quality dashboards that not only flag invalid rows but pin the failing location for analysts. Combined with ST_Buffer on the location, it renders a marker on the map precisely where the geometry breaks.

For automated pipelines it provides both the reason (useful for categorisation) and a point suitable for overlay in web GIS tools.

FAQs

How do I access the individual fields?

Use (ST_IsValidDetail(geom)).valid, .reason, or .location. Remember the parentheses around the function call when accessing composite row fields.

What if the geometry is valid?

valid is true, reason is NULL, and location is NULL.

How is it different from ST_IsValidReason?

ST_IsValidReason returns only the reason text. ST_IsValidDetail returns the full composite row including a location point and the boolean valid flag.

Can the location point be used for repair?

Not directly — use ST_MakeValid for repair. But the location is valuable for manual inspection or targeted editing of a specific problematic vertex.