Reader#

class Reader[source]#

Bases: object

Factory class creating satellite products according to their names.

It creates a singleton that you can call only one time per file.

__init__()[source]#
open(product_path: AnyPathStrType, archive_path: AnyPathStrType = None, output_path: AnyPathStrType = None, method: CheckMethod = CheckMethod.MTD, remove_tmp: bool = False, custom: bool = False, constellation: Union[Constellation, str, list] = None, **kwargs) Product[source]#

Open a product from: - On disk path - Cloud URI (such as s3://) - STAC Item URL

Handled STAC Items are:

  • MPC:
    • S2 L2A COGS

    • Landsat L2 and L1

    • S1 RTC

  • E84:
    • S2 L2A COGS

    • S2 L1C

    • Landsat L2

>>> from eoreader.reader import Reader
>>> path = r"S2B_MSIL1C_20210517T103619_N7990_R008_T30QVE_20210929T075738.SAFE.zip"
>>> Reader().open(path)
eoreader.S2Product 'S2B_MSIL1C_20210517T103619_N7990_R008_T30QVE_20210929T075738'
Attributes:
    condensed_name: 20210517T103619_S2_T30QVE_L1C_075738
    path: D:/S2B_MSIL1C_20210517T103619_N7990_R008_T30QVE_20210929T075738.SAFE.zip
    constellation: Sentinel-2
    sensor type: Optical
    product type: MSIL1C
    default pixel size: 10.0
    default resolution: 10.0
    acquisition datetime: 2021-05-17T10:36:19
    band mapping:
        COASTAL_AEROSOL: 01
        BLUE: 02
        GREEN: 03
        RED: 04
        VEGETATION_RED_EDGE_1: 05
        VEGETATION_RED_EDGE_2: 06
        VEGETATION_RED_EDGE_3: 07
        NIR: 8A
        NARROW_NIR: 08
        WATER_VAPOUR: 09
        CIRRUS: 10
        SWIR_1: 11
        SWIR_2: 12
    needs extraction: False
    cloud cover: 0.155752635193646
    tile name: T30QVE
Parameters:
  • product_path (AnyPathStrType) – Product path. URL to a STAC Item is accepted. Cloud URIs (such as s3://…) or classic paths also.

  • archive_path (AnyPathStrType) – Archive path

  • output_path (AnyPathStrType) – Output Path

  • method (CheckMethod) – Checking method used to recognize the products

  • remove_tmp (bool) – Remove temp files (such as clean or orthorectified bands…) when the product is deleted

  • custom (bool) – True if we want to use a custom stack

  • constellation (Union[Constellation, str, list]) – One or several constellations to help the Reader to choose more rapidly the correct Product

  • **kwargs – Other arguments

Returns:

EOReader’s product

Return type:

Product

valid_mtd(product_path: Union[str, CloudPath, Path], constellation: Union[str, Constellation]) bool[source]#

Check if the product’s mtd is in the product folder/archive

>>> from eoreader.reader import Reader, Constellation
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> With IDs
>>> Reader().valid_mtd(path, "S1")
False
>>> Reader().valid_mtd(path, "S2")
True

>>> # With names
>>> Reader().valid_mtd(path, "Sentinel-1")
False
>>> Reader().valid_mtd(path, "Sentinel-2")
True

>>> # With Constellation
>>> Reader().valid_mtd(path, Constellation.S1)
False
>>> Reader().valid_mtd(path, Constellation.S2)
True
Parameters:
  • product_path (AnyPathStrType) – Product path

  • constellation (Union[str, Constellation]) – Constellation’s name or ID

Returns:

True if valid name

Return type:

bool

valid_name(product_path: Union[str, CloudPath, Path], constellation: Union[str, Constellation]) bool[source]#

Check if the product’s name is valid for the given satellite

>>> from eoreader.reader import Reader, Constellation
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> With IDs
>>> Reader().valid_name(path, "S1")
False
>>> Reader().valid_name(path, "S2")
True

>>> # With names
>>> Reader().valid_name(path, "Sentinel-1")
False
>>> Reader().valid_name(path, "Sentinel-2")
True

>>> # With Constellation
>>> Reader().valid_name(path, Constellation.S1)
False
>>> Reader().valid_name(path, Constellation.S2)
True
Parameters:
  • product_path (AnyPathStrType) – Product path

  • constellation (str) – Constellation’s name or ID

Returns:

True if valid name

Return type:

bool