Skip to content

Commit

Permalink
Use gdal.WarpOptions when merging rasters (#303)
Browse files Browse the repository at this point in the history
* While running notebooks on azure, I ran into a `zero positional`
argument error from gdal.Warp when called from common.merge_rasters.

In looking at the code, I changed to using gdal.WarpOptions which
resolved the error.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
brendancol and pre-commit-ci[bot] committed Aug 9, 2024
1 parent cf231f5 commit fad508f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions samgeo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2992,16 +2992,20 @@ def merge_rasters(
raise ImportError(
"GDAL is required to use this function. Install it with `conda install gdal -c conda-forge`"
)

# Get a list of all the input files
input_files = glob.glob(os.path.join(input_dir, input_pattern))

# Prepare the gdal.Warp options
warp_options = gdal.WarpOptions(
format=output_format, dstNodata=output_nodata, creationOptions=output_options
)

# Merge the input files into a single output file
gdal.Warp(
output,
input_files,
format=output_format,
dstNodata=output_nodata,
options=output_options,
destNameOrDestDS=output,
srcDSOrSrcDSTab=input_files,
options=warp_options,
)


Expand Down

0 comments on commit fad508f

Please sign in to comment.