[postgis-users] problems cleaning geometry - other options?

Kevin Neufeld kneufeld at refractions.net
Thu Dec 4 12:33:12 PST 2008


William Kyngesburye wrote:
> I wonder if there is a way for a postgres function to see what the 
> actual kind of validity error is (it just comes up as a NOTICE: in the 
> sql output)?  

Yes, very new and still in discussion amongst the development team, but it's possible to do this with the development 
branch (svn head) of PostGIS.

postgis=# SELECT ST_IsValidReason(
   'POLYGON (( 0 0, 0 4, 4 4, 4 0, 0 0 ),
             ( 3 5, 2 5, 2 6, 3 6, 3 5 ))'::geometry);
        st_isvalidreason
-------------------------------
  Hole lies outside shell [3 5]
(1 row)


test=# SELECT ST_IsValidReason(
   'POLYGON (( 0 0, 0 4, 4 4, 4 0, 0 0 ),
             ( 2 2, 2 3, 3 3, 5 2, 2 2 ))'::geometry);
      st_isvalidreason
---------------------------
  Self-intersection [4 2.5]
(1 row)


Cheers,
Kevin



More information about the postgis-users mailing list