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

William Kyngesburye woklist at kyngchaos.com
Wed Dec 3 16:08:45 PST 2008


I'm trying to fix some polygons-with-holes imported from shapefiles  
where the main polygon is not the first in the list, one of the hole  
polygons is, making them invalid.

These are 3D multipolygons - imported from the SRTM SWBD shapefiles  
(with GDAL). (file w162n55n if anyone wants to try)

The cleanGeometry funtion at:

http://postgis.refractions.net/support/wiki/index.php?CleanPolygons

isn't working, I get an error:

=>select astext(cleangeometry(wkb_geometry)) from swbd where cell =  
145018 and wb = 353;
NOTICE:  Hole lies outside shell at or near point -161.201 55.9992 0
CONTEXT:  PL/pgSQL function "cleangeometry" line 15 at IF
ERROR:  Dimensions mismatch in lwcurve
CONTEXT:  PL/pgSQL function "cleangeometry" line 19 at assignment

I tried forcing the geometry to 2D (st_force_2d()) and I get a  
different error:

NOTICE:  Hole lies outside shell at or near point -161.201 55.9992
CONTEXT:  PL/pgSQL function "cleangeometry" line 15 at IF
ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
CONTEXT:  PL/pgSQL function "cleangeometry" line 19 at assignment

These shapefiles don't have curved geometry (I'm not sure it's  
supported in shapefiles).


I wonder if there is a simpler operation that could reorder sub- 
polygons to put the one that contains all the others first?  And would  
it be faster or slower?

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"History is an illusion caused by the passage of time, and time is an  
illusion caused by the passage of history."

- Hitchhiker's Guide to the Galaxy





More information about the postgis-users mailing list