Skip to content

Commit d33a3b2

Browse files
authored
Merge pull request #288 from FZJ-IEK3-VSA/284_warpLike_kwargs
284 warp like kwargs
2 parents a746a02 + b82bf42 commit d33a3b2

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

geokit/core/raster.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,10 @@ def warpLike(dataSource: load_raster_input, contextSource: load_raster_input, co
27012701
If True, the metadata of the dataSource raster will be copied, else
27022702
metadata will be empty or as possibly provided in kwargs. Defaults to False.
27032703
**kwargs
2704-
All kwargs will be passed on to raster.warp().
2704+
All kwargs will be passed on to raster.warp()
2705+
NOTE: If no 'dtype' value as kwargs is given, dtype will be defined
2706+
automatically based on the value range, this can be time-consuming
2707+
depending on data size. Avoid by specifying dtype explicitly.
27052708
"""
27062709
if UTIL.isRaster(dataSource):
27072710
dataInfo = rasterInfo(dataSource)
@@ -2719,32 +2722,22 @@ def warpLike(dataSource: load_raster_input, contextSource: load_raster_input, co
27192722
meta = dataInfo.meta
27202723
else:
27212724
meta = kwargs.pop("meta", None)
2722-
print(meta)
2723-
dtype = kwargs.pop("dtype", dataInfo.data_type_name_str)
2724-
noData = kwargs.pop("noData", dataInfo.noData)
2725-
if "cutline" in kwargs:
2726-
# make sure that the cells outside are filled with noData if not specified
2727-
fill = kwargs.pop("fill", dataInfo.noData)
2728-
else:
2729-
# set to default of warp() function for consistent behavior
2730-
fill = inspect.signature(warp).parameters["fill"].default
27312725

27322726
# then get context related parameters from CONTEXT source
27332727
bounds = kwargs.pop("bounds", contextInfo.bounds)
27342728
pixelWidth = kwargs.pop("pixelWidth", contextInfo.pixelWidth)
27352729
pixelHeight = kwargs.pop("pixelHeight", contextInfo.pixelHeight)
27362730
srs = kwargs.pop("srs", contextInfo.srs)
2731+
noData = kwargs.pop("noData", contextInfo.noData)
27372732

27382733
return warp(
27392734
source=dataSource,
27402735
bounds=bounds,
27412736
pixelWidth=pixelWidth,
27422737
pixelHeight=pixelHeight,
2743-
dtype=dtype,
27442738
srs=srs,
27452739
noData=noData,
27462740
meta=meta,
2747-
fill=fill,
27482741
**kwargs,
27492742
)
27502743

0 commit comments

Comments
 (0)