[postgis-users] Raster pixel value
Andreas Forø Tollefsen
andreasft at gmail.com
Thu Nov 24 02:14:29 PST 2011
Hi,
I am trying to calculate the average pixel value in a elevation raster
inside quadrate polygons.
However, I am not getting the correct values from my query:
SELECT gid, AVG(((foo.geomval).val)) as avgmnt
FROM (SELECT p.gid, ST_Intersection(p.cell, r.rast) AS geomval FROM
mountain r, priogrid_land p WHERE ST_Intersects(p.cell, r.rast, ) AND p.gid
=186124) AS foo
GROUP BY gid ORDER BY gid;
The problem here is that the ST_Intersects(geom, rast) takes into
consideration the pixels that is outside, but touches the border of the
quadrate polygons. Then, the average values for each quadrate polygon is
affected by pixels inside other polygons. This will potentially lead to a
flawed result.
So what I want is to be able to calculate the average value for the pixels
INSIDE the polygon excluding those outside.
How can i restrict the AVG pixel value to be calculated only for pixels
that is inside the polygon, and not the pixels that touch the outside of
the border?
Thanks!
Best,
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20111124/9523b005/attachment.html>
More information about the postgis-users
mailing list