sertit / eoreader

Remote-sensing opensource python library reading optical and SAR sensors, loading and stacking bands, clouds, DEM and spectral indices in a sensor-agnostic way.
https://eoreader.readthedocs.io/en/latest/
Apache License 2.0
271 stars 22 forks source link

Nested files .DIM and .TIF for SPOT constellations #145

Closed jteulade closed 1 month ago

jteulade commented 1 month ago

Files METADATA.DIM and IMAGERY.TIF can be found at any level according to this But here, we are looking only at the root of the product. That's why, we get the following error:

Traceback (most recent call last):
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 516, in _get_path
    prod_path = next(self.path.glob(f"{filename}*.{extension}"))
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\JTeulade\repositories\stac\scripts\add_items.py", line 28, in <module>
    add_items(S3_TARGET_PATH, utils.get_ids())
  File "E:\JTeulade\repositories\stac\libs\sertit-utils\sertit\s3.py", line 99, in s3_env_wrapper
    return function(*_args, **_kwargs)
  File "E:\JTeulade\repositories\stac\stac\stac.py", line 255, in add_items
    path_products = create_items(valid_path_products, catalog, s3_target_path)
  File "E:\JTeulade\repositories\stac\stac\stac.py", line 174, in create_items
    item: pystac.Item = prod.stac.create_item()
  File "e:\jteulade\repositories\eoreader\eoreader\products\product.py", line 1424, in stac
    self._stac = StacItem(self)
  File "e:\jteulade\repositories\eoreader\eoreader\stac\stac_item.py", line 69, in __init__
    self.proj = ProjExt(prod, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\stac\stac_extensions.py", line 212, in __init__
    self.geometry = gdf_to_geometry(self.geometry_fct())
  File "C:\Users\jteulade\AppData\Local\anaconda3\envs\arcgispro-eo\lib\site-packages\methodtools.py", line 72, in __call__
    return self.__call__(*args, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\__init__.py", line 34, in wrapper
    return func(*args, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\stac\stac_extensions.py", line 243, in geometry_fct
    return self._prod.footprint().to_crs(self.crs())
  File "C:\Users\jteulade\AppData\Local\anaconda3\envs\arcgispro-eo\lib\site-packages\methodtools.py", line 72, in __call__
    return self.__call__(*args, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\__init__.py", line 34, in wrapper
    return func(*args, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\utils.py", line 364, in simplify_wrapper
    footprint = footprint_fct(self)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\dimap_v1_product.py", line 151, in footprint
    self.get_default_band_path(),
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 139, in get_default_band_path
    return self._get_default_utm_band(self.pixel_size, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 629, in _get_default_utm_band
    def_path = self.get_band_paths([default_band], pixel_size=def_res)[default_band]
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 222, in get_band_paths
    self.ortho_path = self._get_ortho_path(**kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 189, in _get_ortho_path
    ortho_path = self._get_tile_path()
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\spot45_product.py", line 616, in _get_tile_path
    return self._get_path("IMAGERY", "TIF")
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\vhr_product.py", line 519, in _get_path
    raise InvalidProductError(
eoreader.exceptions.InvalidProductError: No file corresponding to **IMAGERY*.TIF found in C:\Users\jteulade\AppData\Local\Temp\tmp162cml_f\SP05_HRG_THX__3_20120729T112957_20120729T113005_TOU_1234_f1ec.DIMA

You can test the following product: s3://sertit-projects-archives/projects/2019/PREFER/Traitements/TEST_SITES/PORTUGAL/Images/SPOT/SP05_HRG_THX__3_20120729T112957_20120729T113005_TOU_1234_f1ec.DIMA.tar

remi-braun commented 1 month ago

The right thing is indeed to only look at the root of the product 👍