Skip to main content

ST_IsSimple

Tests whether a geometry is simple - it has no self-intersections or self-tangencies.

Syntax

ST_IsSimple(geometry)

Parameters

ParameterTypeDescription
geometryGeometryInput geometry to test

Returns

TypeDescription
BooleanTrue if geometry is simple, false otherwise

Examples

Simple LineString

SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(0 0, 1 1, 2 0)'));
-- Returns: true

Self-Intersecting LineString

SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(0 0, 2 2, 2 0, 0 2)'));
-- Returns: false (crosses itself)

Point is Always Simple

SELECT ST_IsSimple(ST_Point(0, 0));
-- Returns: true

Find Non-Simple Features

SELECT id FROM roads
WHERE NOT ST_IsSimple(geom);

Notes

  • Points are always simple
  • LineStrings are simple if they don't cross themselves (except at endpoints for rings)
  • Polygons are simple if they don't have self-intersecting rings
  • Simple is a prerequisite for being valid

See Also