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

Kevin Neufeld kneufeld at refractions.net
Thu Oct 2 09:00:35 PDT 2008


It sounds like you are after computing an overlay of a polygonal dataset.

I might try to first create a set of non-overlapping polygons, then 
generate a point for every distinct new polygon and transfer/sum the 
attributes from your original polygon table using a point-in-polygon 
table join.

Something like this:
http://postgis.refractions.net/support/wiki/index.php?ExamplesOverlayTables
This is not exactly what you want since you are doing a self join with 
your polygonal table, but the logic might work for you.  Also, there are 
probably better ways to produce a set of non-overlapping polygons (like 
first setting aside the distinct polygons - "2" in your example below - 
to make the query faster).

For example, this query will produce a set of non-overlapping polygons.
SELECT geom AS the_geom
FROM ST_Dump((
   SELECT ST_Polygonize(the_geom)
   FROM (SELECT ST_Union(ST_Boundary(the_geom)) AS the_geom
         FROM my_polygons) AS foo
   ));


So, yes, it's possible and I'm sure everyone will have a different 
approach ... but that's the fun thing with GIS, your options are almost 
limitless.

Cheers,
Kevin

Reid Priedhorsky wrote:
> 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



More information about the postgis-users mailing list