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

Fix nodata retrieval logic to ensure compatibility with rioxarray #192

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions odc/geo/_xr_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
)
from .overlap import compute_output_geobox
from .roi import roi_is_empty
from .types import Nodata, Resolution, SomeNodata, SomeResolution, SomeShape, xy_
from .types import Nodata, Resolution, SomeNodata, SomeResolution, SomeShape, Unset, xy_

# pylint: disable=import-outside-toplevel
# pylint: disable=too-many-lines
Expand Down Expand Up @@ -80,6 +80,8 @@
("lat", "lon"),
]

_NoValue = Unset()


@dataclass
class GeoState:
Expand Down Expand Up @@ -1024,11 +1026,11 @@ def nodata(self) -> Nodata:
encoding = self._xx.encoding

for k in ["nodata", "_FillValue"]:
nodata = attrs.get(k, ())
if nodata == ():
nodata = encoding.get(k, ())
nodata = attrs.get(k, _NoValue)
if nodata is _NoValue:
nodata = encoding.get(k, _NoValue)

if nodata == ():
if nodata is _NoValue:
continue

if nodata is None:
Expand Down
Loading