[postgis-users] Raster cell size and wrong mean value calculation problem
Bborie Park
dustymugs at gmail.com
Wed Jan 23 08:05:48 PST 2013
By the looks of the docs for ST_Intersection, what you're getting is
correct. The second paragraph indicates that the raster gets
vectorized using ST_DumpAsPolygon() which does merge neighboring cells
with the same value in one larger geometry.
http://postgis.net/docs/manual-2.0/RT_ST_Intersection.html
The query using ST_Clip is more appropriate.
-bborie
On Wed, Jan 23, 2013 at 6:33 AM, <fLaNsch at gmx.de> wrote:
> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list