Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in handling of temporary VRTs #50

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions S1_NRB/nrb.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ def format(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None,
print(outname)
bounds = [extent['xmin'], extent['ymin'], extent['xmax'], extent['ymax']]

ras = None
if isinstance(ds, tuple):
with Raster(list(ds), list_separate=False) as ras:
source = ras.filename
ras = Raster(list(ds), list_separate=False)
source = ras.filename
elif isinstance(ds, str):
source = tempfile.NamedTemporaryFile(suffix='.vrt').name
gdalbuildvrt(ds, source)
Expand All @@ -186,6 +187,8 @@ def format(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None,
options={'format': driver, 'outputBounds': bounds, 'srcNodata': src_nodata,
'dstNodata': dst_nodata_float, 'multithread': multithread,
'creationOptions': write_options[key]})
if ras is not None:
ras.close()
nrb_tifs.append(outname)

# reformat `snap_datasets` to a flattened list if necessary
Expand Down