[postgis-users] Problems with GeomUnion
Martin Davis
mbdavis at VividSolutions.com
Fri Apr 8 09:33:15 PDT 2005
In JTS buffer is pretty tolerant of invalid topology. That's why I
suggested using it to clean up bad geometry. AFAIK it should have
similar behaviour under GEOS. It's not 100% guaranteed to work,
however, so if there are failures some other approach might be needed
for them.
Fixing topology errors is usually not a simple single-step process - it
can require some deviousness to deal with the infinite number of ways
that geometry can be bad.
Martin Davis, Senior Technical Architect
Vivid Solutions Inc. www.vividsolutions.com
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046
> -----Original Message-----
> From: Bill Binko [mailto:bill at binko.net]
> Sent: April 8, 2005 8:55 AM
> To: PostGIS Users Discussion
> Subject: RE: [postgis-users] Problems with GeomUnion
>
>
> On Fri, 8 Apr 2005, Mark Cave-Ayland wrote:
>
> > Hi Bill,
> >
> > > So, obviously, I have some real issues in this data.
> >
> > This is because you are running a buffer() on a column containing
> > invalid geometries - you need to check the validity
> *before* you pass
> > the geometry to a GEOS function. My guess is that you want
> something
> > like:
> >
> > SELECT oid from parcels where ndims(parcel_shape, 0) != 2)
>
> I was running buffer() on it to FIX the invalid shapes (per Martin's
> suggestion).
>
> I had tried your query before, and it returned zero rows (which makes
> sense given the constraint). The buffer() seemed to be
> converting them to
> non-2d.
>
> >
> > Which will return the oids for all geometries in the parcel_shape
> > column which don't have 2 dimensions.
> >
> Right: there were none.
>
> > > 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.
> >
> > Again, this query fails for the same reason. The following
> SQL should
> > return the oids of all invalid geometries in the
> parcel_shape column
> > of your parcels table:
> >
> > select foo.oid from (select oid, isvalid(parcel_shape) AS valid from
> > parcels) as foo where foo.valid = 'f';
>
> This one gave me a list of 829 invalid shapes (out of 330881). Since
> you're suggesting that buffer() can't be run on them, do you have any
> suggestions on how to correct them? I got lots of
>
> NOTICE: Self-Intersaction
> and
> NOTICE: Ring Self-Intersection
>
> messages while the query was running, along with a few uglier
> lines about null elements. Should I try to match up the
> stderr messages with the OIDs
> (on stdout) and only run buffer() on the ones with NOTICE:
> Self-Intersection?
>
> (Don't get me wrong: I appreciate the help, I'm just flying a
> bit blind
> here.)
>
>
> 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