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 <[email protected]> wrote:

From: Rebecca Clarke <[email protected]>
Subject: [postgis-users] Advice on Unioning Polygons
To: [email protected]
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.5PostgreSQL 8.3.8
Many thanks in advance.

Rebecca


-----Inline Attachment Follows-----

_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Reply via email to