From 82270fbdf139c3b6c559b47a301407a2f2f740f9 Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Tue, 13 Aug 2024 15:38:23 +0200 Subject: [PATCH] FIX: Prune empty keywords from kwargs in `rasters(_rio).write` to avoid throwing GDAL warnings/errors --- CHANGES.md | 1 + sertit/rasters.py | 3 +++ sertit/rasters_rio.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6e60237..900c068 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/sertit/rasters.py b/sertit/rasters.py index b7348c3..287b3de 100644 --- a/sertit/rasters.py +++ b/sertit/rasters.py @@ -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"] diff --git a/sertit/rasters_rio.py b/sertit/rasters_rio.py index 956c549..f08e57e 100644 --- a/sertit/rasters_rio.py +++ b/sertit/rasters_rio.py @@ -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)