There was a commit yesterday about ZonalStats; I would start with looking at 
the test cases for it.

The ArcGrid plugin reads some kind of ascii format?

http://docs.geotools.org/latest/userguide/library/coverage/arcgrid.html

I have not hunted down an example yet; need to look in test cases; here from 
ArcGridVisualisationTest - looks like normal GridCoverage use:

LOGGER.info("Reading the coverage through a file");
// get a gzipped ascii grid
final File f = TestData.file(this, "arcgrid/spearfish.asc.gz");
// Reading the coverage through a file
GridCoverageReader reader = new ArcGridReader(f);
final GridCoverage2D gc1 = (GridCoverage2D) reader.read(null);

LOGGER.info("Reading the gzipped coverage through an ImageInputStream");
// Reading the coverage through an ImageInputStream
final ImageInputStream iiStream = ImageIO
.createImageInputStream( new GZIPInputStream(
new FileInputStream(f)));
reader = new ArcGridReader(iiStream,hints);
final GridCoverage2D gc2 = (GridCoverage2D) reader.read(null);

LOGGER.info(" Reading the gzipped coverage through an InputStream");
// Reading the coverage through an InputStream
reader = new ArcGridReader( new GZIPInputStream(
new FileInputStream(f)),hints);
final GridCoverage2D gc3 = (GridCoverage2D) reader.read(null);

LOGGER.info("Reading the gzipped coverage through a URL");
// Reading the coverage through a URL
reader = new ArcGridReader( f.toURI().toURL(),hints);
final GridCoverage2D gc4 = (GridCoverage2D) reader.read(null);

// show the coverage or try to load the data
if (TestData.isInteractiveTest()) {
gc1.show();
gc2.show();
gc3.show();
gc4.show();
} else {
PlanarImage.wrapRenderedImage(gc1.getRenderedImage()).getTiles();
PlanarImage.wrapRenderedImage(gc2.getRenderedImage()).getTiles();
PlanarImage.wrapRenderedImage(gc3.getRenderedImage()).getTiles();
PlanarImage.wrapRenderedImage(gc4.getRenderedImage()).getTiles();
}

-- 
Jody Garnett

On Tuesday, 10 May 2011 at 4:37 AM, Nick Malleson wrote: 
> 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
> 
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to