Hi Martin,
thanks for your suggestions. Unfortunately they are not really what
I'm looking for.
I need a matrix like object to do operations with the comlete grid.
If I use
> double[] values = null;
> values = GridCoverage2D.evaluate(position, values);
or
> JAI iterators
I'm as far es I'am now (getting a 1D array):
// using java.awt.image.RenderedImage and ~.Raster
RenderedImage renderedImage = gridCoverage.getRenderedImage();
Raster renderedGrid = renderedImage.getData();
// Get size of grid
int gridMinX = renderedGrid.getMinX();
int gridMinY = renderedGrid.getMinY();
int gridWidth = renderedGrid.getWidth();
int gridHeight = renderedGrid.getHeight();
// pass image data to double[]
double[] dataBlock = null;
dataBlock = renderedGrid.getPixels(gridMinX, gridMinY, gridWidth,
gridHeight, dataBlock);
That works fine.
The problem occurs, if I do the next step:
double[][] gridValues = new double[gridHeight][gridWidth];
int base;
for (int i=0; i<gridHeight; i++) {
base = i * gridWidth;
System.arraycopy(dataBlock, base, gridValues[i], 0, gridWidth);
}
This is applicable for smaller grids (1000 x 500 pixels) but crashes
when I try to pass larger ones.
I also tried to copy one pixel after the other, rather than complete
lines, using two nested for-loops, leading to the same error.
It must be possible to get a 2D-array of a grid without any memory
exception! I don't get it.
Christian
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users