Name

ST_IsSimple — Tests if a geometry has no points of self-intersection or self-tangency.

Synopsis

boolean ST_IsSimple(geometry geomA);

Description

Returns true if this Geometry has no anomalous geometric points, such as self-intersection or self-tangency. For more information on the OGC's definition of geometry simplicity and validity, refer to "Ensuring OpenGIS compliance of geometries"

Use the valid field from ST_IsValidDetail to check whether a polygon has a valid shell and holes. A polygon can be simple even when one of its holes lies outside the shell.

[Note]

SQL-MM defines the result of ST_IsSimple(NULL) to be 0, while PostGIS returns NULL.

This method implements the OGC Simple Features Implementation Specification for SQL 1.1. s2.1.1.1

This method implements the SQL/MM specification. SQL-MM 3: 5.1.8

This function supports 3d and will not drop the z-index.

Examples

Code
SELECT ST_IsSimple('POLYGON((1 2,3 4,5 6,1 2))');
Output
f
Figure
Geometry figure for visual-st-issimple-01
Code
SELECT ST_IsSimple('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)');
Output
f
Figure
Geometry figure for visual-st-issimple-02

A polygon with a hole outside its shell is simple and invalid.

Code
WITH input(geom) AS (
  VALUES ('POLYGON((0 0,4 0,4 4,0 4,0 0),
                    (5 5,5 6,6 6,6 5,5 5))'::geometry)
)
SELECT ST_IsSimple(geom) AS simple,
       (ST_IsValidDetail(geom)).valid AS valid
FROM input;
Output
 simple | valid
--------+-------
 t      | f
(1 row)
Figure
Geometry figure for visual-st-issimple-03

See Also

ST_IsValid