Skip to content

BUG: Use the default nodata value when clipping integer data without nodata - #969

Open
VolodymyrLinuxovich wants to merge 1 commit into
vylor:masterfrom
VolodymyrLinuxovich:clip-integer-nodata
Open

VolodymyrLinuxovich wants to merge 1 commit into
vylor:masterfrom
VolodymyrLinuxovich:clip-integer-nodata

Conversation

@VolodymyrLinuxovich

Copy link
Copy Markdown
Contributor

Clipping integer data with no nodata value masked pixels with NaN. The cast back to the integer dtype then raised a RuntimeWarning and left arbitrary values in those pixels. On my machine they came out as 0, so they looked like real data. This is also what #694 reports for uint8.

The in memory clip now fills masked pixels with the default nodata value for the dtype. It is the same table that reproject already uses. The value is written to the output so the masked pixels can be told apart. Float data and data with a nodata value are unchanged. The from_disk path is unchanged too.

The new test covers uint8, int16 and int32 and fails on master.

…nodata

Masked pixels were NaN cast to the integer dtype, which raised a RuntimeWarning and left arbitrary values. They now get the default nodata value for the dtype, and it is written to the output. Closes vylor#717
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.64%. Comparing base (ae6635a) to head (fd6a5ff).
⚠️ Report is 253 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #969      +/-   ##
==========================================
+ Coverage   95.90%   96.64%   +0.73%     
==========================================
  Files          12       18       +6     
  Lines        1735     2177     +442     
==========================================
+ Hits         1664     2104     +440     
- Misses         71       73       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Check data type and/or better error msg for rioxarray.clip

1 participant