jiayuasu commented on code in PR #3312:
URL: https://github.com/apache/sedona/pull/3312#discussion_r3926863488
##########
common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java:
##########
@@ -62,6 +63,19 @@ public static byte[] asGeoTiff(
throw new RuntimeException(e);
}
ParameterValueGroup defaultParams =
writer.getFormat().getWriteParameters();
+ // Without this, GeoTiffWriter writes a default GDAL_NODATA of 0 for
coverages that
+ // have no no-data value, so a cleared (or never set) no-data value comes
back as 0
+ // when the written bytes are read again.
+ boolean hasNoDataValue = false;
+ for (int band = 1; band <= raster.getNumSampleDimensions(); band++) {
+ if (RasterBandAccessors.getBandNoDataValue(raster, band) != null) {
+ hasNoDataValue = true;
+ break;
+ }
+ }
+ defaultParams
+ .parameter(GeoTiffFormat.WRITE_NODATA.getName().toString())
+ .setValue(hasNoDataValue);
Review Comment:
Do we need to preserve the GeoTools opt-out here? With
`-Dgeotiff.writenodata=false`, the descriptor default is false, but this
overwrites it with true whenever any band has NoData, so `RS_AsGeoTiff` emits
`GDAL_NODATA` despite the explicit setting. Could we only force false for the
no-NoData case and otherwise leave the configured default alone?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]