[postgis-users] Problems with GeomUnion

strk at refractions.net strk at refractions.net
Fri Apr 8 09:32:38 PDT 2005


On Fri, Apr 08, 2005 at 11:08:59AM -0400, Bill Binko wrote:
> On Thu, 7 Apr 2005, Martin Davis wrote:
> 
> > > Now I need a way to fix self-intersecting shapes.  
> > 
> > If you do a buffer(0) on the shapes as you load them (or after you load
> > them), that will convert them to valid geometry while preserving their
> > outline.
> > 
> 
> I'm having some issues with that solution (and I was very excited to hear 
> such a simple one!).  When I run this:
> 
> update parcels set parcel_shape = buffer(parcel_shape, 0);
> 
> I get:
> 
> ERROR:  new row for relation "parcels" violates check constraint "enforce_geotype_parcelShape"

What version of postgis/geos are you running ?
Could you provide an .sql file containing the 2d geometry that
fed to buffer(0) becomes a non-2d one ? 
--strk;

> 
> that constraint looks like:
> 
> Check constraints:
>     "enforce_dims_parcelShape" CHECK (ndims(parcel_shape) = 2)
> 
> I thought I'd check which ones weren't of dimension 2, so I ran:
> 
> SELECT oid from parcels where ndims(buffer(parcel_shape, 0)) != 2)
> 
> That gives me:
> 
> NOTICE:  IllegalArgumentException: points must form a closed linestring
> NOTICE:  IllegalArgumentException: geometries must not contain null elements
> 
> ERROR:  POSTGIS2GEOS conversion failed
> 
> So, obviously, I have some real issues in this data.
> 
> I thought I might get to the bottom of it with this query:
> 
> gis=# select oid from (select oid, isvalid(buffer(parcel_shape, 0)) as valid from parcels) as foo where valid = false;
> 
> But I got:
> 
> ERROR:  invalid memory alloc request size 0
> 
> That can't be good. :-(
> 
> Anyway, I'm still plugging at it, so any help is fabulous.
> 
> 
> > > I wonder why I didn't get errors when loading the shapefiles into the
> > database!
> > 
> > Shapefiles are notoriously tolerant of invalid geometry topology.  For
> > different reasons, so is PostGIS.  Sometimes it's nice to be able to
> > load invalid geometry and then clean it up in a subsequent step.  If
> > PostGIS refused to load your bad shape, you might have no way of knowing
> > what the bad linework was or what the error was.
> > 
> 
> Understood: I'll just have to learn how to clean it up :)
> 
> Bill
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list