ST_IsValidReason
What is ST_IsValidReason?
ST_IsValidReason returns a human-readable description of why a geometry fails OGC validity — for example, "Self-intersection at or near point (...)" — or the string "Valid Geometry" when the input is valid.
1ST_IsValidReason(geometry geom) → text
2ST_IsValidReason(geometry geom, integer flags) → textflags = 1 enables the ESRI-relaxed profile. The textual reason is useful in data-quality reports and SQL audits.
When would you use ST_IsValidReason?
Use ST_IsValidReason in data ingestion pipelines to categorise invalid geometries — self-intersection, duplicate vertices, interior ring not contained — and drive automated remediation or manual review. Grouping by reason string also helps spot systematic issues from a specific data source.
It is more efficient than parsing the output of ST_IsValidDetail when you only need the reason string and not the failure location.
FAQs
What does it return for valid geometry?
The string "Valid Geometry". All other strings indicate a failure.
Can I filter by reason to find specific issues?
Yes. WHERE ST_IsValidReason(geom) LIKE 'Self-intersection%' isolates rows with crossing rings, a common repair target.
Does it use the same check as ST_IsValid?
Yes — same underlying GEOS validity routine. The difference is the return type (text vs boolean).
Is it faster or slower than ST_IsValid?
Slightly slower because the reason string must be constructed. For pure true/false filtering, use ST_IsValid.