Skip to content

Commit 432d0a6

Browse files
committed
Updated to copy input image data to output array rather than assigning so output data type is maintained. Hopefully fixing a potential bug.
1 parent d74c526 commit 432d0a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/rsgislib/imagecalc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ def recode_int_raster(
13841384
recode_dict: Dict[int, int],
13851385
keep_vals_not_in_dict: bool = True,
13861386
gdalformat: str = "KEA",
1387-
datatype: bool = rsgislib.TYPE_32INT,
1387+
datatype: int = rsgislib.TYPE_32INT,
13881388
):
13891389
"""
13901390
A function recodes an input image. Assuming image only has a single image band so
@@ -1428,7 +1428,7 @@ def recode_int_raster(
14281428
def _recode(info, inputs, outputs, otherargs):
14291429
out_arr = numpy.zeros_like(inputs.inimage[0], dtype=otherargs.np_dtype)
14301430
if otherargs.keep_vals_not_in_dict:
1431-
out_arr = inputs.inimage[0]
1431+
numpy.copyto(out_arr, inputs.inimage[0], casting='same_kind')
14321432

14331433
for rc_val in recode_dict:
14341434
out_arr[inputs.inimage[0] == rc_val] = recode_dict[rc_val]

0 commit comments

Comments
 (0)