[postgis-users] Fix "Ring self-intersection" problem

Kevin Neufeld kneufeld at refractions.net
Mon Nov 1 20:04:58 PDT 2010


On 11/1/2010 4:29 PM, ByronCinNz wrote:
>      SELECT
>          ST_BuildArea(
>              ST_Union(
>                  ‘LINESTRING EMPTY’,
>                  ST_ExteriorRing(
>                      ‘POLYGON((...))’
>              )
>      )
>
> The circumstances in which this method fails is when there are interior
> rings inside the invalid polygon.
> The interior rings disappear - which would be expected because the process
> is only looking for exterior rings.

Try using ST_Boundary() instead of ST_ExteriorRing().  It will return 
the linework that makes up a polygon (the exterior and interior rings).  
You could also try buffering your polygon by 0, ST_Buffer(geom, 0).  
This has the side effect of deconstructing and reconstructing your polygon.

-- Kevin



More information about the postgis-users mailing list