Kristin Cowalcijk created SEDONA-360:
----------------------------------------
Summary: Handle nodata values of raster bands in a more concise way
Key: SEDONA-360
URL: https://issues.apache.org/jira/browse/SEDONA-360
Project: Apache Sedona
Issue Type: Improvement
Reporter: Kristin Cowalcijk
Fix For: 1.5.0
GeoTools handles nodata values in a strange manner: The
[GridSampleDimension#getNoDataValues|https://github.com/geotools/geotools/blob/28.4/modules/library/coverage/src/main/java/org/geotools/coverage/GridSampleDimension.java#L765]
method treats any non-quantitative categories as nodata values when there's
not a category named "No data".
This code fragment demonstrates this behavior. When "No data" category exists,
{{getNoDataValues}} gives the value of that category as nodata value; once we
remove that category, it gives us even more nodata values:
{code:java}
Category[] categories = {
new Category(Category.NODATA.getName(), new Color(0, 0, 0, 0), 10),
new Category("Land", new Color(87, 154, 60, 255), 1),
new Category("Water", new Color(0, 0, 255, 255), 2),
new Category("Cloud", new Color(255, 255, 255, 255), 3),
new Category("GrayScale", (Color) null, NumberRange.create(100, 200))
};
GridSampleDimension sampleDimension = new GridSampleDimension("test",
categories, null);
double[] noDataValues = sampleDimension.getNoDataValues();
// noDataValues is [10]
{code}
{code:java}
Category[] categories = {
new Category("Land", new Color(87, 154, 60, 255), 1),
new Category("Water", new Color(0, 0, 255, 255), 2),
new Category("Cloud", new Color(255, 255, 255, 255), 3),
new Category("GrayScale", (Color) null, NumberRange.create(100, 200))
};
GridSampleDimension sampleDimension = new GridSampleDimension("test",
categories, null);
double[] noDataValues = sampleDimension.getNoDataValues();
// noDataValues is [1, 2, 3]
{code}
While when writing GeoTiff files, the GeoTiffWriter finds category named "No
data" for nodata value. (See
[here|https://github.com/geotools/geotools/blob/28.4/modules/plugin/geotiff/src/main/java/org/geotools/gce/geotiff/GeoTiffWriter.java#L235-L238]
and
[here|https://github.com/geotools/geotools/blob/28.2/modules/library/coverage/src/main/java/org/geotools/coverage/util/CoverageUtilities.java#L280])
The same thing happens in the ArcGrid writer. (See
[here|https://github.com/geotools/geotools/blob/28.2/modules/plugin/arcgrid/src/main/java/org/geotools/gce/arcgrid/ArcGridWriter.java#L552]).
To make the behavior of finding nodata value consistent with the file writing
process and PostGIS, we'll treat values in categories named "No data" as nodata
values.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)