[postgis-users] area() weighted statistics?
Stephen Woodbridge
woodbri at swoodbridge.com
Fri Oct 10 13:04:46 PDT 2008
Have you tried doing a sub query that computes the areas and then only
do the sums in the main query?
-Steve
Jeff Hamann wrote:
>
> I'm trying to create a set of 'unioned' polygons where the statistics
> are the area weighted average from the areas of the adjacenct polygons
> using PostGIS (which rocks, btw) using something like the following code:
>
> SELECT
> ( area( GeomUnion( mat2.the_geom ) ) * mat2.initage ) / sum(
> area( GeomUnion( mat2.the_geom ) ) ) as wtinitage,
> GeomUnion( the_geom ) as boundary
> FROM mat2, (SELECT mat2.the_geom FROM mat2 ) AS s;
>
>
> ch1-# ERROR: aggregate function calls cannot be nested
>
>
> which would suggest that I cannot perform a query like this:
>
> select area(a.the_geom)*a.attr / sum( area( GeomUnion( a.the_geom ) )
>
> where the denominator is a temp table that contains the unioned
> geometries. I'm thinking I might have to perform this process in a few
> steps. Is that correct, or is there a 'one-liner' method to union a set
> of polygons that touch, such that a set of values can be weighted by
> area of the polygons, before the union? I'm having to to this many steps
> to make sure, I'm getting correct results, but have lose data when I
> geomunion to get a set of touching polygons together.
>
>
> Thanks
> Jeff.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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