diff --git a/extensions/aproc/proc/download/drivers/impl/tif_file.py b/extensions/aproc/proc/download/drivers/impl/tif_file.py index faab32af..348fa440 100644 --- a/extensions/aproc/proc/download/drivers/impl/tif_file.py +++ b/extensions/aproc/proc/download/drivers/impl/tif_file.py @@ -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 @@ -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 @@ -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) - - - diff --git a/extensions/aproc/proc/download/drivers/impl/utils.py b/extensions/aproc/proc/download/drivers/impl/utils.py index aebf7bd4..258892ef 100644 --- a/extensions/aproc/proc/download/drivers/impl/utils.py +++ b/extensions/aproc/proc/download/drivers/impl/utils.py @@ -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)