Hi,
I'm using geotools 8.1 (with a maven project), and am trying to get the
Minimum and Maximum values for a the single band that is contained in a
file.
The code I am using is:
File file = new File("/home/xxx/grid.asc");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
reader = format.getReader(file);
GridCoverage2D coverage = reader.read(null);
System.out.println("Num Dimensions: " +
coverage.getNumSampleDimensions());
System.out.println("Min value: " +
coverage.getSampleDimension(0).getMinimumValue());
System.out.println("Max value: " +
coverage.getSampleDimension(0).getMaximumValue());
I know the max value is 1739, the min value is 1 and the NODATA value is
-99999 by inspecting the grid in SAGA but the above code outputs:
Num Dimensions: 1
Min value: -99999.0
Max value: -99999.0
I have also tried using:
NumberRange range = coverage.getSampleDimension(0).getRange();
System.out.println(coverage.getSampleDimension(0).getSampleDimensionType().identifier());
System.out.println("Min value: " + range.getMinimum());
System.out.println("Max value: " + range.getMaximum());
But this also outputs the incorrect values:
CV_64BIT_REAL
Min value: -99999.0
Max value: -99999.0
When displaying the map with a ColorMap it does show correctly so the above
output is confusing. Am I using the correct methods or is there another
way I could easily obtain the min/max without scanning the whole file? Is
this just a limitation of ascii file format?
Any help would be greatly appreciated. I hope I have provided enough
detail.
Thanks,
Lauchlin
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users