Skip to content
Snippets Groups Projects
Commit fb8e69db authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Allowed tuple objects to be passed to warp_ndarray().

parent 9ca01bad
Branches
Tags
No related merge requests found
Pipeline #
......@@ -295,12 +295,12 @@ def warp_ndarray(ndarray, in_gt, in_prj=None, out_prj=None, out_dtype=None,
"'cubic' is used instead. To avoid this please update GDAL to a version above 2.0.0!")
rspAlg = 'cubic'
if not isinstance(ndarray, list):
if not isinstance(ndarray, (list, tuple)):
assert str(np.dtype(ndarray.dtype)) in dTypeDic_NumPy2GDAL, "Unknown target datatype '%s'." % ndarray.dtype
else:
assert str(np.dtype(ndarray[0].dtype)) in dTypeDic_NumPy2GDAL, "Unknown target datatype '%s'." % ndarray.dtype
assert isinstance(in_gt, list), "If 'ndarray' is a list, 'in_gt' must also be a list!"
assert isinstance(in_prj, list), "If 'ndarray' is a list, 'in_prj' must also be a list!"
assert isinstance(in_gt, (list, tuple)), "If 'ndarray' is a list, 'in_gt' must also be a list!"
assert isinstance(in_prj, (list, tuple)), "If 'ndarray' is a list, 'in_prj' must also be a list!"
assert len(list(set([arr.dtype for arr in ndarray]))) == 1, "Data types of input ndarray list must be equal."
def get_SRS(prjArg):
......@@ -309,7 +309,7 @@ def warp_ndarray(ndarray, in_gt, in_prj=None, out_prj=None, out_dtype=None,
def get_GDT(DT): return dTypeDic_NumPy2GDAL[str(np.dtype(DT))]
in_dtype_np = ndarray.dtype if not isinstance(ndarray, list) else ndarray[0].dtype
in_dtype_np = ndarray.dtype if not isinstance(ndarray, (list, tuple)) else ndarray[0].dtype
# # not yet implemented
# # TODO cutline from OGR datasource. => implement input shapefile or Geopandas dataframe
......@@ -394,7 +394,7 @@ def warp_ndarray(ndarray, in_gt, in_prj=None, out_prj=None, out_dtype=None,
"""
# get input dataset (in-MEM)
if not isinstance(ndarray, list):
if not isinstance(ndarray, (list, tuple)):
in_ds = get_GDAL_ds_inmem(ndarray, in_gt, in_prj)
else:
# list of ndarrays
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment