If the below conditions are true, then I would say you can do this in PostGIS.
A solution that comes to mind is this SELECT Sum(score) as totscore, ST_Union(the_geom) as newgeom FROM poly GROUP BY CAST(random()*10000 As int) HAVING All_Disjoint(the_geom) Set the 10000 so some function of the size of your set. You always want it to be lower than the number of polygons you have. The larger the number the fewer polygons you would expect per match. All_Disjoint is a yet to be defined aggregate function you will need to create yourself that checks each incoming geometry against the previous set and returns true if it is disjoint (not intersecting) any of the previous. Unfortunately the above will not use indexes. Aggregates are pretty easy to create in PostgreSQL so I'll leave that as an exercise for you to figure out. The answers to the above will probably give different answers each time since it does a random walk. Hope that helps, Regina -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Obe, Regina Sent: Thursday, October 02, 2008 10:28 AM To: PostGIS Users Discussion Subject: RE: [postgis-users] "summing" (polygon, float) pairs Reid, I assume 1) You don't care if polygons are reused to form your new sets 2) You don't care how many polygons are in each set. 3) You also are not looking for all possible permutations - just a random set of answers that solve your equation? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Reid Priedhorsky Sent: Wednesday, October 01, 2008 6:35 PM To: PostGIS Users Discussion Subject: [postgis-users] "summing" (polygon, float) pairs Dear all, I have a set of polygons. Associated with each polygon is a number; call it score. Each polygon can intersect with zero or more other polygons. What I would like to compute is a set of non-intersecting polygons with summed scores -- each of these polygons would be a set of points where the sum of all the original polygons' scores covered by the result polygon are equal. Here's an example in one dimension: Input: ----3------ ----1---- ----4---- ----2---- Output: --3-- -4- -8- -5- -4- ----2----- It is OK if two adjacent result polygons have equal sums. Can this be done in PostGIS? Reid p.s. thanks for the help on my question a few days ago! I felt a tad foolish after learning it was just a missing isvalid() constraint. I thought I had one but didn't look carefully enough. _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer. _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
