Skip to content

Commit

Permalink
FIX: Prune empty keywords from kwargs in rasters(_rio).write to avo…
Browse files Browse the repository at this point in the history
…id throwing GDAL warnings/errors
  • Loading branch information
remi-braun committed Aug 13, 2024
1 parent 097b022 commit 82270fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **ENH: Add a function `snap.get_snap_version` to retrieve current SNAP version** ([#172](https://github.com/sertit/eoreader/issues/172))
- **ENH: Allow to pass directly a version object to `misc.compare_version`**
- FIX: Prune empty keywords from kwargs in `rasters(_rio).write` to avoid throwing GDAL warnings/errors

## 1.41.0 (2024-08-06)

Expand Down
3 changes: 3 additions & 0 deletions sertit/rasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,9 @@ def write(
>>> # Rewrite it
>>> write(xds, raster_out)
"""
# Prune empty kwargs to avoid throwing GDAL warnings/errors
kwargs = {k: v for k, v in kwargs.items() if v is not None}

# Manage dtype
if "dtype" in kwargs:
dtype = kwargs["dtype"]
Expand Down
3 changes: 3 additions & 0 deletions sertit/rasters_rio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,9 @@ def write(
"""
raster_out = raster.copy()

# Prune empty kwargs to avoid throwing GDAL warnings/errors
kwargs = {k: v for k, v in kwargs.items() if v is not None}

# Manage raster type (impossible to write boolean arrays)
if raster_out.dtype == bool:
raster_out = raster_out.astype(np.uint8)
Expand Down

0 comments on commit 82270fb

Please sign in to comment.