[postgis-users] Raster cell size and wrong mean value calculation problem
fLaNsch at gmx.de
fLaNsch at gmx.de
Wed Jan 23 06:33:05 PST 2013
Hi Postgis User-list,
i've downloaded and migrated some srtm3 rasterdata into my PostgreSQL/Postgis 2.0 Database successfully. Now i would like to calculate the mean elevation value of a given polygon area by intersecting my polygon layer with the raster grid.
Using a SQL-Statement, which was shown by Pierre Racine at the FOSS4G 2011:
SELECT polyID,
(ST_Intersection(geom, rast)).geom poly,
(ST_Intersection(geom, rast)).val elevation
FROM polygon, srtm WHERE ST_Intersects(geom, rast);
What i expected the polygon-result geometry would look like:
_ _ _ _
|_|_|_|_|
|_|_|_|_|
|_|_|_|_|
|_|_|_|_|
What the result actually looks like:
_ _ _ _
|___|_ |
|_ |_| |
|_|___|_|
|_|_|_|_|
The raster cells with the same elevation value got merged, why?
The mean value which based on the actual result cannot be correct. Same result different SQL-Statement without selecting the geometry:
Select polyid,(stats).mean from (Select a.polyid,st_summarystats(st_clip(b.rast,1,a.geom))as stats from polygon a, srtm b where ST_intersects(a.geom,b.rast )
I'm very grateful for any help!
Best regards,
Simon
More information about the postgis-users
mailing list