[postgis-users] Making one out of several connected polygons?
Simon Schneider
Kallas at gmx.de
Fri Feb 1 06:09:35 PST 2008
Great seems to do exactly what I need. But when I tried to test it with
some simple samples:
create table objects
(
name varchar(15) not null primary key,
parent varchar(15),
type varchar(15) not null
);
select addgeometrycolumn('objects','geom3d',-1,'POLYGON',3);
insert into objects(name, type, geom3d) values('Room01', 'room',
(GeomFromEWKT('POLYGON((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0))')));
insert into objects(name, type, geom3d) values('Room02', 'room',
(GeomFromEWKT('POLYGON((10 0 0, 20 0 0, 20 10 0, 10 10 0, 10 0 0))')));
select astext(geom3d) from (select geomunion(objects.geom3d)::geometry
from objects) as foo;
it says: ERROR: column "geom3d" does not exist
Did I miss something or what's going wrong?
Nicolas Ribot schrieb:
> Try to geomunion() your polygons.
> It will create a multipolygon where touching polygons will be unioned.
> then, use dump() on the geomunion to extract each polygon.
>
> Example:
> the polygon table contains:
>
> test=# select id, astext(geometry) from tpoly2;
> id | astext
> ----+--------------------------------------------------------------------
> 1 | POLYGON((166 272,107 210,145 142,218 158,209 215,182 240,166 272))
> 2 | POLYGON((242 118,218 158,145 142,167 104,242 118))
> 3 | POLYGON((76 161,145 142,167 104,112 78,76 161))
> | POLYGON((284 174,283 112,320 124,295 129,302 156,284 174))
> (4 rows)
>
> The query to extract unioned polygon based on a common edge:
>
> select astext(geom(dump(geom))), path(dump(geom))
> from (select geomunion(t1.geometry)::geometry as geom
> from tpoly2 t1
> ) as foo;
>
> Leads to this result:
> astext
> | path
> -------------------------------------------------------------------------------------------------+------
> POLYGON((284 174,302 156,295 129,320 124,283 112,284 174))
> | {1}
> POLYGON((76 161,145 142,107 210,166 272,182 240,209 215,218 158,242
> 118,167 104,112 78,76 161)) | {2}
> (2 rows)
>
> (see polygon.png and result.png images done with openjump)
>
> HTH
>
> Nicolas
> On 01/02/2008, Simon Schneider <Kallas at gmx.de> wrote:
>> Hi,
>>
>> I've several polygons wich are all connected by at least one line and
>> I'm looking for a way to make one big polygon which contains all the
>> others. In other words the shape of the polygoncluster.
>>
>> I've been locking around for quite a while but I found no way to solve
>> this within postgis.
>>
>>
>> Cheers,
>> Simon
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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