[postgis-users] Advice on geometry collection to multipolygonapproach

Francois Hugues hugues.francois at irstea.fr
Mon Feb 18 04:57:45 PST 2013


Hi,

We do not see your whole query but maybe you should add a where
st_intersects clause between the geometries you are intersecting to
avoid empty geometry collections.

The dump solution will return a record for each component of the
geometry collection : simple objects or multi. St_multi(st_dump(geom))
will show you them as multi ones. If you have another attribute to union
your geometries you can also try something like
st_multi(st_union((st_dump(geom)).geom))

Hugues.
 

________________________________

From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of David Quinn
Sent: Monday, February 18, 2013 1:15 PM
To: PostGIS Users Discussion
Subject: [postgis-users] Advice on geometry collection to
multipolygonapproach


Hi List,

What is the best way of converting a geometry collection to a
multipolygon in PostGIS 2.0? I have tried the following approach:

st_multi (
        st_union (
            st_intersection (
                st_buffer (t.point, radius), s.geom
            )                    
        )
    ) as geom

This results in the following error message: 
"ERROR: Geometry type (GeometryCollection) does not match column type
(MultiPolygon) SQL state: 2202" 
and I don't understand why I am getting this message. I've also seen
examples that use st_dump/st_collect using but am less sure if this
returns a multipolygon:

st_collect (
        st_dump (
            st_intersection (
                st_buffer (t.point, radius), s.geom
            )                    
        )
    ) as geom

Which approach should I use? My intersection query can return a single
geometry or a geometry collection.

Thanks,
David 


More information about the postgis-users mailing list