Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproject replaces 0 with -1 if nodata is not set #172

Open
simonreise opened this issue Jul 20, 2024 · 2 comments
Open

Reproject replaces 0 with -1 if nodata is not set #172

simonreise opened this issue Jul 20, 2024 · 2 comments

Comments

@simonreise
Copy link

I have a custom Landsat cloud mask based on QA band with values 0 and 1 and a Landsat panchromatic band. When I try to match cloud mask to a resolution of a panchromatic band with odc.reproject, 0's in a mask are replaced with -1's.

mask_pan = mask.odc.reproject(pan.odc.geobox).persist()
mask.rio.nodata == None                  # True (nodata is not set)
mask_pan.rio.nodata == None              # True (nodata is not set)
mask.data[0][2000][2000].compute()       # 0 (0 - data, 1 - cloud)
mask_pan.data[0][4000][4000].compute()   # -1 (panchromatic band is 2x larger than the others)
np.unique(mask)                          # array([0, 1])
np.unique(mask_pan)                      # array([-1,  1])

But, for example, if we set a nodata in mask, or pass dst_nodata=-1 arg, then 0's are not replaced.

Also, it happens only if data is integer, and everything works correctly if data is float.

P.S. Here is also a notebook with minimum examples that shows the cases when this bug occurs and when it does not.
https://colab.research.google.com/drive/1MPoYkNOsBAZ6CBOSitYxtR1mhwn1QMU5?usp=sharing

@SpacemanPaul
Copy link
Contributor

Hi Simon.

  1. What odc-geo version are you using?
import odc.geo as geo
geo.__version__
  1. mask_pan.odc.nodata == mask_pan.rio.nodata?

@simonreise
Copy link
Author

  1. odc-geo version: 0.4.8
  2. mask_pan.odc.nodata == mask_pan.rio.nodata is True

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

No branches or pull requests

2 participants