[postgis-users] Problems with GeomUnion

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Fri Apr 8 09:33:22 PDT 2005


Hi Bill, 

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] On 
> Behalf Of Bill Binko
> Sent: 08 April 2005 16:55
> 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.

Right, I see now. What does the following SQL give you (it you should give
you the number of dimensions for buffer(parcel_shape, 0) for all valid
geometries where the dimension is not equal to 2):

SELECT foo.oid, ndims(buffer(foo.parcel_shape, 0)) FROM (SELECT oid,
parcel_shape FROM parcels WHERE isvalid(parcel_shape) = 't') AS foo WHERE
ndims(buffer(foo.parcel_shape, 0)) != 2

(cut)

> > 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?

This is beginning to get out of my knowledge area - have you seen the
earlier post about using JUMP to validate features?


Kind regards,

Mark.

------------------------
WebBased Ltd
South West Technology Centre
Tamar Science Park
Plymouth
PL6 8BT 

T: +44 (0)1752 791021
F: +44 (0)1752 791023
W: http://www.webbased.co.uk





More information about the postgis-users mailing list