Skip to content

Commit b86c6b1

Browse files
authored
Merge pull request #22 from FrontierDevelopmentLab/bugfix/corrupted-bands
Add task id to vsimem to avoid multiple tasks using the same in-memory file
2 parents 5f48a5d + 625e288 commit b86c6b1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def read(*names, **kwargs):
3333

3434
setup(
3535
name="satextractor",
36-
version="0.2.1",
36+
version="0.3.0",
3737
license="BSD-2-Clause",
3838
description="SatExtractor. Extract everything from everywhere.",
3939
url="https://github.com/FrontierDevelopmentLab/sat-extractor",

src/satextractor/extractor/extractor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ def download_and_extract_tiles_window(
170170
for i, url in enumerate(urls):
171171
content = download_f(url)
172172

173-
gdal.FileFromMemBuffer("/vsimem/content", content.read())
174-
d = gdal.Open("/vsimem/content", gdal.GA_Update)
173+
gdal.FileFromMemBuffer(f"/vsimem/{task.task_id}_content", content.read())
174+
d = gdal.Open(f"/vsimem/{task.task_id}_content", gdal.GA_Update)
175175

176176
proj = osr.SpatialReference(wkt=d.GetProjection())
177177
proj = proj.GetAttrValue("AUTHORITY", 1)
@@ -182,12 +182,12 @@ def download_and_extract_tiles_window(
182182
if int(proj) != epsg:
183183
file = gdal.Warp(
184184
f"{task.task_id}_warp.vrt",
185-
"/vsimem/content",
185+
f"/vsimem/{task.task_id}_content",
186186
dstSRS=f"EPSG:{epsg}",
187187
creationOptions=["QUALITY=100", "REVERSIBLE=YES"],
188188
)
189189
else:
190-
file = "/vsimem/content"
190+
file = f"/vsimem/{task.task_id}_content"
191191

192192
out_f = f"{task.task_id}_{i}.jp2"
193193
gdal.Translate(
@@ -197,6 +197,7 @@ def download_and_extract_tiles_window(
197197
projWinSRS=f"EPSG:{epsg}",
198198
xRes=resolution,
199199
yRes=resolution,
200+
resampleAlg="cubic",
200201
creationOptions=["QUALITY=100", "REVERSIBLE=YES"],
201202
)
202203
file = None

0 commit comments

Comments
 (0)