[postgis-users] Union of MultiPolygons

Paul Ramsey pramsey at cleverelephant.ca
Wed Nov 26 11:10:40 PST 2008


Probably your multipolygons are merging into a proper polygon.

INSERT INTO county (polygon_nm, the_geom) VALUES ('X',
st_multi(st_union((select the_geom from county where polygon_nm='LAKE'), (select
the_geom from county where polygon_nm='COOK'))))

Yes, st_union can operate as an aggregate.

CREATE TABLE states_from_couties AS
select st_multi(st_union(the_geom)) from county
group by state;

P.

On Wed, Nov 26, 2008 at 11:02 AM, C. Y. W. <cyw at dls.net> wrote:
> Hi All,
>
> I have  a table with counties as Multipolygons. I need to define a new
> multipolygon with some of these counties.
>
> I tried to run this :
>
> INSERT INTO county (polygon_nm, the_geom) VALUES ('X',
> st_union((select the_geom from county where polygon_nm='LAKE'), (select
> the_geom from county where polygon_nm='COOK')))
>
> And I got constraint "enforce_geotype_the_geom" violations.
>
> I guess st_union returns something that's not a Multipolygon.
>
> What should I do?
>
> Anyway to merge more than 2 Multipolygons at a time?
>
> Thanks,
> cyw
>
> _______________________________________________
> 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