[postgis-users] Polygon validity

Kevin Neufeld kneufeld at refractions.net
Wed Mar 31 09:26:53 PDT 2010


On 3/30/2010 11:46 PM, Andrea Peri wrote:
> You can use the ST_IsSimple to know if a geometry is simple-feature.
>
> If true it is simple-feature.
>
> After, if you geometry is ST_IsSimpe = true,
> you can test with ST_IsValid , to detect eventually invalidity for geometry.
>
> So you can detect if it is a simple-feature valid geometry.
>

This is often something that is easily misunderstood.  So, to be clear, according to the OGC specs, simplicity really 
*only* applies to point and linear features ([multi]point, [multi]linestrings).  Validity on the other hand *only* 
applies to areal features ([multi]polygons).  I put together some thoughts [1] a while back on this.

The OGC specs aren't totally clear regarding duplicate points in linestrings, just that "has no anomalous geometric 
points, such as self intersection or self tangency" and "is simple if it does not pass through the same point twice". 
The developers at the time decided that this does not include duplicate points.  I suppose one could argue either way, 
but to me this really does include duplicate points.

PostGIS also somewhat subscribes to the SQL/MM specifications.  In there I read "is not simple if any interior point has 
the same location as another interior point or a point on the boundary".  To me, this is more clear and, Rykov, I think 
you're right, ST_IsSimple really should not allow duplicate points.  I'll put in a ticket.

So, simplicity is for lines and points.
A *polygon* is *valid* iff all the underlying linear features are *simple* (like no figure 8's in the boundary) and also 
follows several other rules (like the inner rings being contained within the exterior ring, etc).

Rykov, this is why your polygon passes validity - currently PostGIS does not include duplicate points in linestrings 
(the boundary of your polygon) as non-simple.

Cheers,
Kevin

[1] http://postgis.refractions.net/docs/ch04.html#OGC_Validity



More information about the postgis-users mailing list