Skip to content

Commit

Permalink
Merge pull request #22 from FrontierDevelopmentLab/bugfix/corrupted-b…
Browse files Browse the repository at this point in the history
…ands

Add task id to vsimem to avoid multiple tasks using the same in-memory file
  • Loading branch information
frandorr authored Dec 2, 2021
2 parents 5f48a5d + 625e288 commit b86c6b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit b86c6b1

Please sign in to comment.