[postgis-users] "summing" (polygon, float) pairs

Obe, Regina robe.dnd at cityofboston.gov
Thu Oct 2 09:08:50 PDT 2008


Martin,

Your interpretation was much more useful than my interpretation. I was
wandering why Reid would want to do such a silly thing. Thought maybe he
was bored.

I guess I read it wrong. Are never mind then what I said.

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Martin Davis
Sent: Thursday, October 02, 2008 12:03 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] "summing" (polygon, float) pairs

I read the original request as asking how to create a non-overlapping 
coverage from a set of overlapping polygons, and attribute each face of 
the coverage with the sum of its parent polygons' scores.  I think this 
is different to your solution.

AFAIK the best way to create a non-overlapping coverage from a set of 
overlapping polygons is to extract the linework (boundaries) from the 
polygons, node it together (by unioning all the lines) and then 
re-polygonize.  A point-in-polygon for each new face against the 
original set can be used to determine the parents, and then the summing 
is easy.

Obe, Regina wrote:
> 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: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] 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: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] 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
> postgis-users at postgis.refractions.net
> 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
> 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
>
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
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.



More information about the postgis-users mailing list