According to the comments in CoverageUtilities.getBackgroundValues() it
will try to fetch the background value from one of "no data" categories.
Actually it returns the value from the background category.
The background category is usually different from the no data category
in coverages produced by some readers I tried (aaig/aig/tiff).
I would like the method to return the actual nodata value. Should it not
return that already? The reason is that when doing a crop operation with
a ROI I want it to set the cropped out cells to the no data value. I
guess I could rebuild the coverage and set the background category to
the no data category.
Example program output:
---
Categories: GeophysicsCategoryList([-32,768 ... -32,768])
‣ GeophysicsCategory("No data":[-32768.0 ... -32768.0])
Background category: Category("No data":[0...0])
Actual no data value: -32768.0
CoverageUtilities.getBackgroundValues(): [0.0] <---- I would like this
to be -32768.0
---
Example program
public static void main(String[] args) throws Exception {
InputStream aaigInput = new ByteArrayInputStream((
"NCOLS 2\nNROWS 2\nXLLCORNER 0.0\nYLLCORNER 0.0\nCELLSIZE
1.0\nNODATA_VALUE -32768\n" +
"0 -32768 " +
"-32768 1").getBytes("US-ASCII"));
GridCoverage2D c = new ArcGridReader(aaigInput).read(null);
System.out.printf("Categories: %s\n",
c.getSampleDimension(0).getCategories());
System.out.printf("Background category: %s\n",
c.getSampleDimension(0).getBackground());
InternationalString s =
Vocabulary.formatInternational(VocabularyKeys.NODATA);
Double nodata = null;
for(Category cat: c.getSampleDimension(0).getCategories()) {
if(s.equals(cat.getName())) {
nodata = cat.getRange().getMinimum();
}
}
System.out.printf("Actual no data value: %s\n", nodata == null ?
"unknown" : nodata);
System.out.printf("CoverageUtilities.getBackgroundValues(): %s\n",
Arrays.toString(CoverageUtilities.getBackgroundValues(c)));
}
Matthijs
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users