[postgis-users] Making one out of several connected polygons?
Simon Schneider
Kallas at gmx.de
Fri Feb 1 06:26:23 PST 2008
Silly me, I found the error.
With
select astext(geom) from (select geomunion(geom3d)::geometry as geom
from objects) as foo
everything worked fine.
thx
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