On Fri, Jun 20, 2008 at 12:51 AM, Dan D'Alimonte <[EMAIL PROTECTED]> wrote:
> I cannot seem to get a WritableRaster (or
> some other manner of modifying the cells of the raster in the grid) back
> out of a GridCoverage2D once I have created the spatially referenced grid.

Dan,

Do you mean you want to modify the values in an existing coverage ?
That's quite possible, but for map algebra I generally have one or
more coverages as inputs to some operation, the result of which is a
new output coverage.

To get at the raster data GridCoverage2D.getRenderedImage is your friend.

Also, have a look at the geotools helper class ImageWorker.

Here's an example (note: there are probably much more elegant ways of
doing this :)

        // binary thresholding: output pixels are 1 where input pixels
>= min value; 0 otherwise

        RenderedImage image = mycoverage.getRenderedImage();
        ImageWorker iworker = new ImageWorker(image);
        iworker.binarize(minValue);

        // create output coverage

        RenderedImage outImage = iworker.getRenderedImage();
        Envelope2D envelope = mycoverage.getGridGeometry().getEnvelope2D();
        GridCoverageFactory factory =
CoverageFactoryFinder.getGridCoverageFactory(null);
        GridCoverage2D result = factory.create("result", outImage, envelope);


Michael

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to