Skip to content

Commit 786b3f3

Browse files
frandorrcarderne
authored andcommitted
Add task id to vsimem to avoid multiple tasks using the same in-memory file. Also change interpolation to cubic when using translate
1 parent c17cb0b commit 786b3f3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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)