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


##########
common/src/main/java/org/apache/sedona/common/raster/RasterBandEditors.java:
##########
@@ -53,14 +55,22 @@ public static GridCoverage2D setBandNoDataValue(
 
     // Remove no-Data if it is null
     if (noDataValue == null) {
-      if (RasterBandAccessors.getBandNoDataValue(raster) == null) {
+      if (rasterNoData == null) {
         return raster;
       }
       GridSampleDimension[] sampleDimensions = raster.getSampleDimensions();
       sampleDimensions[bandIndex - 1] =
           RasterUtils.removeNoDataValue(sampleDimensions[bandIndex - 1]);
-      return RasterUtils.clone(
-          raster.getRenderedImage(), null, sampleDimensions, raster, null, 
true);
+      // The GC_NODATA sentinel also rides on the rendered image itself as an 
image
+      // property and survives serialization there, so cloning the image would 
let
+      // readers and writers resurrect the cleared value. Copy the pixels into 
a
+      // property-free image and drop the sentinel from the coverage 
properties too.
+      Map propertyMap = raster.getProperties();
+      if (propertyMap != null) {
+        propertyMap.remove(NoDataContainer.GC_NODATA);
+      }
+      WritableRaster pixels = raster.getRenderedImage().copyData(null);

Review Comment:
   fixed



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