[GH-3330] Preserve other raster bands when replacing NoData - #3347
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
rasteralgebraTestpassed: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.