Michael,
Thanks very much for your advise, and I like to reference your class
about wrapping a GridCoverage2D. Would please send me a copy?
在2009-05-11,"Michael Bedward" <[email protected]> 写道:
>Hello,
>
>One approach that I use is to access the backing image of the grid
>coverage, wrap it in a JAI (Java Advanced Imaging) TileImage object
>and then use a JAI iterator to set values. So far this has worked
>well for me, and takes advantage of JAI's ability to handle with
>images that are too big to fit into available memory.
>
>A simple example...
>
>import javax.media.jai.TiledImage;
>import javax.media.jai.iterator.RandomIterFactory;
>import javax.media.jai.iterator.WritableRandomIter;
>
>...
>
>// create a TiledImage object that shares the coverage's image data
>TiledImage tImg = new TiledImage(myCoverage.getRenderedImage(), true);
>
>// create a writable iterator
>WritableRandomIter iter = RandomIterFactory(timg, null);
>
>// set a pixel value
>float newValue = ...
>int pixelX = ...
>int pixelY = ...
>int band = ...
>iter.setSample(pixelX, pixelY, band, newValue);
>
>If you need to work in the geo coordinate space rather than the
>coverages image coordinate space...
>
>MathTransform2D worldToGrid = null;
>try {
> worldToGrid = grid.getGridGeometry().getGridToCRS2D().inverse();
>} catch (NoninvertibleTransformException ex) {
> throw new RuntimeException("Could not create geographic to grid
>coords transform");
>}
>
>Point2D geoCoords = ...
>Point2D pixelCoords = new Point2D.Double();
>try {
> worldToGrid.transform(geoCoords, pixelCoords);
>} catch (TransformException ex) {
> throw new RuntimeException("Could not transform location");
>}
>
>I recall someone on the list saying that this TiledImage approach can
>sometimes fail but so far it has worked well for me in this context
>(if that someone - sorry memory fails me - has more details on this
>please chime in).
>
>For one of my own projects where I needed to regularly update coverage
>values, I wrote a class that wraps GridCoverage2D and provides setter
>methods that cache the new values. When the coverage is queried or
>rendered the cache is flushed and the values written to the coverages
>backing image using the method described above. Happy to share that
>code if it sounds applicable to your case.
>
>Michael
>
>
>2009/5/11 zeng <[email protected]>:
>> Hi, all
>> ??? I want to write a function has a gridcoverage2d parameter and return a
>> gridcoverage2d, what need I do is to change the samples value of the raster.
>> I don't want to create a new gridcoverage2d and return it, is there any way?
>>
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users