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.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to