[postgis-users] Problems with GeomUnion

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Fri Apr 8 08:39:28 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:09
> To: PostGIS Users Discussion
> Subject: RE: [postgis-users] Problems with GeomUnion


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

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)

Which will return the oids for all geometries in the parcel_shape column
which don't have 2 dimensions.

> 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';

Kind regards,


WebBased Ltd
South West Technology Centre
Tamar Science Park
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