What is the difference between st_isvalid and st_issimple?

Viewed 472

In Postgis there are two very similar functions. One is st_isValid, the other one is st_isSimple. I'd like to understand the difference between both for Polygons. For the st_isValid we have:

Some of the rules of polygon validity feel obvious, and others feel arbitrary (and in fact, are arbitrary).

  • Polygon rings must close.
  • Rings that define holes should be inside rings that define exterior boundaries.
  • Rings may not self-intersect (they may neither touch nor cross one another).
  • Rings may not touch other rings, except at a point.

For the st_isSimple we've got:

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 compliancy of geometries"

Does it mean that any valid polygon is automatically simple?

1 Answers

Both functions check for similar OGC definition compliancy of geometries, but are defined for different geometries (by dimension);

By OGC definition

  • a [Multi]LineString can (should) be simple

  • a [Multi]Polygon can (should) be valid

This implies that

  • a simple [Multi]LineString is always considered valid

  • a valid [Multi]Polygon is always considered simple (as in, it must have at least one simple closed LineString ring)

thus the answer is yes.


Strictly speaking, using the inherent checks of the OGC defined functionality on the 'wrong' geometry type is useless.

PostGIS, however, liberally extends the functionality of ST_IsValid to use the correct checks for all geometry types.

Related