Skip to content

Commit

Permalink
Ensure nodata=nan tags are written to floating point COGs. (#355)
Browse files Browse the repository at this point in the history
* Ensure nodata=nan tags are written to floating point COGs.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Typo.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix logic and cleanup.

* Use numpy.nan for consistency with core.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
SpacemanPaul and pre-commit-ci[bot] authored Jul 15, 2024
1 parent b9b4a31 commit 2c23131
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eodatasets3/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ def write_from_ndarray(
"driver": "GTiff",
"predictor": self.PREDICTOR_DEFAULTS[dtype],
}
# Ensure 'nan' is always tagged as nodata for floating point types
if nodata is None and numpy.issubdtype(array.dtype, numpy.floating):
nodata = numpy.nan

if nodata is not None:
rio_args["nodata"] = nodata

Expand Down

0 comments on commit 2c23131

Please sign in to comment.