Skip to content

[GH-3330] Preserve other raster bands when replacing NoData - #3347

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix/nodata-preserve-bands
Sep 13, 2026
Merged

[GH-3330] Preserve other raster bands when replacing NoData#3347
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix/nodata-preserve-bands

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Yes, I have read the Contributor Rules and Contributor Development Guide.

Is this PR related to a ticket?

Closes #3330.

What changes were proposed in this PR?

RS_SetBandNoDataValue(raster, band, value, true) creates a new writable raster when replacing existing NoData samples. Previously, it filled only the selected band, leaving every other band's pixels at zero.

Copy the source raster into the new raster before replacing the selected band's samples. This preserves the other bands and leaves the source unchanged.

How was this patch tested?

The new Java regression fails without the fix. It covers all six pixel types and each target band in a three-band raster, checking all pixel values, NoData values, grid geometry, data type, and source preservation. A SQL regression also checks fractional samples and materialized raster serialization.

On Java 11 and Spark 3.5.0, 59 Java tests and all 169 tests in rasteralgebraTest passed:

mvn -B -pl spark/common -am spotless:apply \
  -Dtest=RasterBandEditorsTest,RasterBandAccessorsTest,SerdeTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false \
  -Dsuites=org.apache.sedona.sql.rasteralgebraTest package

Formatting and pre-commit checks passed.

Did this PR include necessary documentation updates?

No documentation changes are needed. This restores the existing function's expected behavior.

@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Sep 13, 2026
@jiayuasu
jiayuasu merged commit 98bb35c into apache:master Sep 13, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RS_SetBandNoDataValue with replace=true zeroes every band except the target one

1 participant