|
From: agawrons <ale...@gm...> - 2012-06-01 00:51:41
|
I'm new to geomatics and GeoTools so this might be a silly question, but I'm
really stuck. I want to extract pixel data from a geoTiff image as a double
array but no matter what I try, all I get are zeros.
Here is my code:
File file = new File("./input/ASAR_04232010.tif");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
AbstractGridCoverage2DReader reader = format.getReader(file);
GridCoverage2D coverage = reader.read(null);
RenderedImage rendImage = coverage.getRenderedImage();
Raster raster = rendImage.getData();
Envelope2D dim = coverage.getEnvelope2D();
double[] array = new double[100];
array = raster.getPixels((int)dim.x + 1, (int)dim.y + 1, 100, 0, array);
for(double num : array){
System.out.println(num + "");
}
I tried a different file and got the same result. Unfortunately the files
are too large to attach.
Thanks in advance!
Alex
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Retrieving-Pixel-Data-tp4978427.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
|