ST_IsSimple
What is ST_IsSimple?
ST_IsSimple is a PostGIS function that returns true if a geometry has no anomalous geometric points — for lines, no self-intersections or self-tangencies; for multi-geometries, no duplicate components.
ST_IsSimple(geometry g) → booleanDefined by the OGC Simple Features specification. Simplicity is a weaker notion than validity — all valid polygons are simple, but not all simple lines are valid rings.
When would you use ST_IsSimple?
Use ST_IsSimple to find lines that cross themselves (a common issue in imported street networks or hand-digitized linework) or multi-geometries with duplicate parts:
1SELECT id, geom
2FROM roads
3WHERE NOT ST_IsSimple(geom); -- self-intersecting linesRemediation depends on the context: split a self-intersecting line with ST_Node + ST_Dump, or dedupe multi-components with ST_Union + ST_Dump.
FAQs
How is ST_IsSimple different from ST_IsValid?
ST_IsSimple applies primarily to lines and multi-geometries. ST_IsValid applies mainly to polygons and checks for ring validity, self-intersection within rings, hole containment, and orientation.
What does "anomalous" mean for points?
For a MULTIPOINT, duplicates are non-simple. For POINT, the result is always true.
How do I fix a non-simple linestring?
Run ST_Node to introduce nodes at self-intersections, then ST_Dump the result into individual simple linestrings.
Is the check fast?
Roughly O(n log n) in vertex count. Fine for routine data; can be slow on extremely dense lines — consider ST_Simplify first if you only need an approximate answer.