[postgis-users] Raster geomval return integer

Andreas Forø Tollefsen andreasft at gmail.com
Thu Oct 27 02:48:40 PDT 2011


Hi all,

I have been working on this issue previously, but now we have updated
to rev 8001 and the ticket 650 is fixed.
Hence, I wanted to see if I can calculate the average pixelvalue
within my grid cells (.5x.5 decimal degrees).

However, I now experience that any value above 0 becomes 1, and i do
not get the actual averaged value.
I also tested to group by the polygonized pixel value, and this
revealed that everything other than 0 is 1.
According to my raster this is not correct, since I have many other
values within the cells borders (see jpg).

I have tried to use the ST_Value(rast, ST_SetSRID(ST_Point(lat,long))
and this give me the correct pixel values.
However, I do not understand what is giving me integer values using
the query below.

Any ideas on what is wrong with my query?

Query:
SELECT gid,CAST(((foo.geomval).val) AS decimal(8,6)) AS mntval,
CAST(SUM(ST_Area((foo.geomval).geom)) AS decimal(8,5)) as area,
CAST(SUM(ST_Area((foo.geomval).geom))/0.25*100 AS decimal(6,3)) as percentarea
FROM (SELECT p.gid, ST_Intersection(ST_SetSRID(r.rast,4326),
ST_SetSRID(p.cell,4326)) AS geomval FROM mountain r, priogrid_land p
WHERE ST_Intersects(ST_SetSRID(p.cell,4326), ST_SetSRID(r.rast,4326))) AS foo
WHERE gid = 183230 AND (foo.geomval).val >= 0
GROUP BY gid, (foo.geomval).val
ORDER BY gid;

Result:
183230;1.000000;0.06945;27.778
183230;0.000000;0.18055;72.222


Best,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 183230.jpg
Type: image/jpeg
Size: 42014 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20111027/1e5ee0a9/attachment.jpg>


More information about the postgis-users mailing list