[postgis-users] Is st_isvalidreason singular for any polygon, or can multiple errors be returned?

Ben Madin lists at remoteinformation.com.au
Mon Dec 19 05:20:09 PST 2011


I guess the answer to my question is in the question, but I've noticed that if I run a statement looking for not isvalid geometries, I get something like :

=#   SELECT gid, ccode, admin1, mapcode, st_mem_size(the_geom), st_isvalidreason(the_geom) FROM summ.polbnda WHERE st_isvalid(the_geom) IS FALSE ORDER BY 2, 3;
NOTICE:  Ring Self-intersection at or near point 123.055 10.9102
NOTICE:  Ring Self-intersection at or near point 121.007 5.68846
 gid | ccode |      admin1       | mapcode | st_mem_size |              st_isvalidreason               
-----+-------+-------------------+---------+-------------+---------------------------------------------
 120 | PHL   | NEGROS OCCIDENTAL |    3592 |      105387 | Ring Self-intersection[123.054838 10.91023]
  84 | PHL   | SULU              |    3556 |      212748 | Ring Self-intersection[121.007041 5.688462]
(2 rows)

at which time I zoom into the locations in QGIS and remove the offending part of the geometry.

After fixing the two, I run the same query, and 

 gid | ccode |      admin1       | mapcode | st_mem_size |               st_isvalidreason               
-----+-------+-------------------+---------+-------------+----------------------------------------------
 120 | PHL   | NEGROS OCCIDENTAL |    3592 |      105339 | Ring Self-intersection[123.310249 10.960445]
(1 row)

So again I go in a repair, and so it goes - It ended up taking about 8 iterations to fix everything.

So my question is - when running st_isvalidreason does it just return the first invalid problem it finds, or do I need a more sophisticated query to return all the problem points? My motivation is that re-running the query is taking a long time (it's a very high resolution set of geometries), so it would be great to get all of the offenders so I could work around each polygon once.

This in : POSTGIS="1.5.3" GEOS="3.3.1-CAPI-1.7.1" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.3" USE_STATS

cheers

Ben





More information about the postgis-users mailing list