Commit 341c7bce authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed TypeError in get_GDAL_ds_inmem() in case nodata has a numpy data type.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent f1e151c8
Pipeline #25513 passed with stages
in 2 minutes and 16 seconds
......@@ -2,6 +2,12 @@
History
=======
0.17.6 (2021-07-12)
-------------------
* Fixed TypeError in get_GDAL_ds_inmem() in case nodata has a numpy data type.
0.17.5 (2021-07-06)
-------------------
......
......@@ -71,6 +71,14 @@ def get_GDAL_ds_inmem(array, gt=None, prj=None, nodata=None):
for i in range(ds.RasterCount):
band = ds.GetRasterBand(i + 1)
try:
# band.SetNoDataValue does not support numpy data types
if isinstance(nodata, np.bool_):
nodata = bool(nodata)
elif isinstance(nodata, np.integer):
nodata = int(nodata)
elif isinstance(nodata, np.floating):
nodata = float(nodata)
band.SetNoDataValue(nodata)
except TypeError:
raise TypeError(type(nodata), 'TypeError while trying to set NoDataValue to %s. ' % nodata)
......
......@@ -19,5 +19,5 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.17.5'
__versionalias__ = '20210706_01'
__version__ = '0.17.6'
__versionalias__ = '20210712_01'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment