james-willis commented on code in PR #3312:
URL: https://github.com/apache/sedona/pull/3312#discussion_r3927155990


##########
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:
   done



-- 
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]

Reply via email to