[postgis-users] Combines polygons within a specified distanceto each other into new polygons.

Peter Freimuth pfreimuth at arcor.de
Sat Sep 5 17:55:48 PDT 2009

```Paragon Corporation schrieb:
> Peter,
> For the harder case where the reference is arbitrary and you are trying to
> calculate many convex hulls.  This will be much slower -- depending on size
> of your table. First thought that comes to mind is a self join.
> The HAVING clause is to try to minimize on a geometry being collected in
> more than one convex hull set.  Its not guaranteed though and also depending
> on your pattern, it may miss some.
>
> SELECT a.gid, ST_ConvexHull(ST_Collect(the_geom)) As convhull
> FROM table_of_polygons As a INNER JOIN table_of_polygons As b ON
> ST_DWithin(a.the_geom, b.the_geom, some_max_dist)
> GROUP BY a.gid
> HAVING a.gid = MIN(b.gid);
>
> Hope that helps,
> Regina
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Paragon
> Corporation
> Sent: Saturday, September 05, 2009 11:07 AM
> To: 'PostGIS Users Discussion'
> Subject: Re: [postgis-users] Combines polygons within a specified distanceto
> each other into new polygons.
>
> Peter,
> You would use a combination of ST_DWithin, ST_Collect, and ST_ConvexHull.
> When you say within a max distance -- you mean of a reference geometry or
> from each other?  From each other can be kind of expensive.
>
> So something of the form
>
> SELECT ST_ConvexHull(ST_Collect(the_geom))
> FROM table_of_polygons
> WHERE ST_DWithin(ST_GeomFromText(.....), the_geom, max_dist)
>
> http://postgis.refractions.net/documentation/manual-svn/ST_ConvexHull.html
>
> http://postgis.refractions.net/documentation/manual-svn/ST_Collect.html
>
> http://postgis.refractions.net/documentation/manual-svn/ST_GeomFromText.html
>
> http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html
>
> Leo
>
>
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Peter
> Freimuth
> Sent: Saturday, September 05, 2009 9:26 AM
> To: PostGIS Users Discussion
> Subject: [postgis-users] Combines polygons within a specified distance to
> each other into new polygons.
>
> Hi PostGIS User,
> i am searching for a postgis based solution to create a convexhull on groups
> of polygons which are grouped via a max distance value.
>
>
>
> Any idea or a solution is welcome!
>
> Kind regards,
> Peter
>
>
>
>
find attached the polygons which i try to aggregate and a screenshot of
how it should look like at the end (brown are the results of the
aggregation that i would like to produce and pink are the original
polygons).
The solution you proposed  did'nt produce the results that i want. Maybe
i make a mistake.

Kind regards,
Peter

--
Peter Freimuth  Muskauer Str. 11   10997 Berlin
Location:http://www.berlinonline.de/citymap/map.asp?start.x=5&plz=10997&str=Muskauer+Str.+11&grid=dedatlas10
========================================================================================================
Tel:+49(0)30-69816610  Mobil:+49(0)175-8434074  Firma:+49(0)3381-8904327
========================================================================================================
mailto:pfreimuth at arcor.de
skype:pfreimuth
msn:peter_freimuth at hotmail.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: aggregate_polygons2.png
Type: image/png
Size: 53705 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090906/c9776f20/attachment.png>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: polygons.sql
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090906/c9776f20/attachment.ksh>
```