[postgis-users] Advice on Unioning Polygons

Rebecca Clarke r.clarke83 at gmail.com
Fri Feb 1 03:05:54 PST 2013


Thanks for your help Brent.

My OS is Debian.



On Fri, Feb 1, 2013 at 10:57 AM, <pcreso at pcreso.com> wrote:

> Hi Rebecca,
>
> Sounds like you are doing this in a script, but you didn't specify your OS.
>
> If so, then as each iteration completes, you can accumulate the id's of
> the polygons dealt to already, & test against this list to avoid creating
> the duplicates. Either in a file or in a table.
>
> Along the lines of:
>
> for polygon in <list of polygon ids> do
>   if id not in list of unioned id's; then
>     add ids to be unioned in this iteration to the list of unioned ones
>     union them
>   end of if
> move to next polygon id
>
> You might consider making the unioned polygons a multipolygon, just in
> case some of them are.
>
> There are improved functions & performance with later versions of postgres
> & postgis, so you might consider upgrading.
>
> HTH,
>
>   Brent Wood
>
>
> --- On *Fri, 2/1/13, Rebecca Clarke <r.clarke83 at gmail.com>* wrote:
>
>
> From: Rebecca Clarke <r.clarke83 at gmail.com>
> Subject: [postgis-users] Advice on Unioning Polygons
> To: postgis-users at lists.osgeo.org
> Date: Friday, February 1, 2013, 11:40 PM
>
>
> Hi there
>
> Looking for some advice.
>
> I have a table with thousands of polygon records.
>
> I want to union all intersecting polygons that have the same attributes
> into one polygon (So one record, rather than 10 or 20 etc.).
>
> Can anyone recommend the best way to do this.
>
> I can do a loop which goes through each record, unions its geometry with
> the geometry's of the other matching records that intersect with it, then
> move to the next record. Problem with this is that it creates
> duplicate polygons when it comes to a record that has already been unioned
> with a previous one record. I can easily delete any duplicate records
> generated, but I'm wondering if there's a less long winded way.
>
> I hope I'm explaining myself correctly.
>
> My details are:
> postgis 1.3.5
> PostgreSQL 8.3.8
>
> Many thanks in advance.
>
> Rebecca
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org<http://mc/compose?to=postgis-users@lists.osgeo.org>
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130201/dbe27378/attachment.html>


More information about the postgis-users mailing list