Hi Nick, If the polygon zones are not groups of pixels, i.e. the polygon zones divide pixels, you can decide how a pixel value will contribute to each polygone zone statistic. For 2D data, you can calculate how much area of a divided pixel is in each polygon zone. For a count statistic, you may reasonably add an areal proportion of the count. I used to do this by checking the intersection of each corner of a pixel with the zonal coverage. That is perhaps better than using pixel centroids. A more thorough way is to turn each pixel (or group of contiguous pixels with the same value) into polygons and intersect these with the zonal polygons and aggregate the intersected result. This is more thorough as there can be cases where all four corners and centroid of a pixel are in one polygon zone, but without the entire pixel being in that zone.
Sorry, I don't know about any GeoTools implementations of this, but I'm interested. Cheers, Andy ________________________________________ From: Nick Malleson [[email protected]] Sent: 09 May 2011 19:37 To: [email protected] Subject: [Geotools-gt2-users] Calculating zonal statistics for a grid coverage Hi, I was wondering if anyone has some advice about calculating zonal statistics from a raster file. Basically I have a raster DTM and a polygon shapefile and I want to calculate, for each area in the shapefile, the average height values of all pixels within that area. (Exactly the same thing that the "Zonal Statistics" function in ArcMap). The information about a http://docs.geotools.org/latest/userguide/library/coverage/grid.html GridCoverage looks relevant, but my data is in ArcGrid ASCII format and as far as I can see at the moment only TIFF data are supported. I've also had a look at the discussion about the ArcGridReader class http://osgeo-org.1803224.n2.nabble.com/Reading-Ascii-Grid-td5470106.html here but I think that the class is no longer used (I'm using GeoTools version 8 and can't find an artefact matching the class name using maven/NetBeans). As the raster data is in text format I suppose I could read it in myself and manually find out in which area each pixel is located (by creating a Point object from pixel centroids and using the within() function with objects in the shapefile) but I'd hoped that someone would have written this already. In particular I'm sure there's a more accurate way of deciding which pixel is in which zone rather than just using the centroids. Any help would be really appreciated, Nick Malleson -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Calculating-zonal-statistics-for-a-grid-coverage-tp6345278p6345278.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
