Skip to content

Commit

Permalink
Fix tiff download
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed May 25, 2024
1 parent 9f60577 commit f998e0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions extensions/aproc/proc/download/drivers/impl/tif_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from airs.core.models.model import Item, Role
from airs.core.models.model import Item, Role, Asset
from aproc.core.settings import Configuration
from extensions.aproc.proc.download.drivers.driver import Driver as DownloadDriver
from datetime import datetime
Expand All @@ -16,7 +16,7 @@ def supports(item: Item) -> bool:
if item.assets.get(Role.data.value) is not None:
asset = item.assets.get(Role.data.value)
file_name = os.path.basename(asset.href)
return file_name.lower().endswith(".tif")
return file_name.lower().endswith(".tif") or file_name.lower().endswith(".tiff")
else:
return False

Expand All @@ -38,6 +38,3 @@ def fetch_and_transform(self, item: Item, target_directory: str, file_name: str,
target_file_name = os.path.splitext(tif_file_name)[0] + datetime.now().strftime("%d-%m-%Y-%H-%M-%S")+'.JP2'
extract(crop_wkt, tif_file, driver_target, epsg_target, target_directory, target_file_name,
target_projection)



2 changes: 2 additions & 0 deletions extensions/aproc/proc/download/drivers/impl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def extract(crop_wkt, file, driver_target, epsg_target, target_directory, target
srs.ImportFromEPSG(int(str(src.crs).split(":")[1]))
out_image, out_transform = rasterio.mask.mask(src, [geom], crop=crop_wkt is not None)
out_meta = src.meta.copy()
if driver_target == 'JP2OpenJPEG' and isinstance(out_meta['dtype'], str) and not out_meta['dtype'].startswith('uint'):
out_meta['dtype'] = 'uint8'
default_transform, width, height = calculate_default_transform(epsg_src.crs, epsg_target.crs,
out_image.shape[2], out_image.shape[1],
*geom.bounds)
Expand Down

0 comments on commit f998e0e

Please sign in to comment.