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

Add task id to vsimem to avoid multiple tasks using the same in-memory file #22

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def read(*names, **kwargs):

setup(
name="satextractor",
version="0.2.1",
version="0.3.0",
license="BSD-2-Clause",
description="SatExtractor. Extract everything from everywhere.",
url="https://github.com/FrontierDevelopmentLab/sat-extractor",
Expand Down
9 changes: 5 additions & 4 deletions src/satextractor/extractor/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def download_and_extract_tiles_window(
for i, url in enumerate(urls):
content = download_f(url)

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

proj = osr.SpatialReference(wkt=d.GetProjection())
proj = proj.GetAttrValue("AUTHORITY", 1)
Expand All @@ -182,12 +182,12 @@ def download_and_extract_tiles_window(
if int(proj) != epsg:
file = gdal.Warp(
f"{task.task_id}_warp.vrt",
"/vsimem/content",
f"/vsimem/{task.task_id}_content",
dstSRS=f"EPSG:{epsg}",
creationOptions=["QUALITY=100", "REVERSIBLE=YES"],
)
else:
file = "/vsimem/content"
file = f"/vsimem/{task.task_id}_content"

out_f = f"{task.task_id}_{i}.jp2"
gdal.Translate(
Expand All @@ -197,6 +197,7 @@ def download_and_extract_tiles_window(
projWinSRS=f"EPSG:{epsg}",
xRes=resolution,
yRes=resolution,
resampleAlg="cubic",
creationOptions=["QUALITY=100", "REVERSIBLE=YES"],
)
file = None
Expand Down