S3SlstrProduct

class S3SlstrProduct(product_path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], archive_path: Optional[Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path]] = None, output_path: Optional[Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path]] = None, remove_tmp: bool = False)[source]

Bases: eoreader.products.optical.s3_product.S3Product

Class of Sentinel-3 SLSTR Products

Methods

__init__(product_path[, archive_path, ...])

https://sentinels.copernicus.eu/web/sentinel/technical-guides/sentinel-3-slstr/level-1/observation-mode-desc Note that the name of each netCDF file provides information about it's content. The suffix of each filename is associated with the selected grid: "an" and "ao" refer to the 500 m grid, stripe A, respectively for nadir view (n) and oblique view (o) "bn" and "bo" refer to the 500 m grid, stripe B "in" and "io" refer to the 1 km grid "fn" and "fo" refer to the F1 channel 1 km grid "tx/n/o" refer to the tie-point grid for agnostic/nadir and oblique view.

clean_tmp()

Clean the temporary directory of the current product

default_transform(**kwargs)

Returns default transform data of the default band (UTM), as the rasterio.warp.calculate_default_transform does: - transform - width - height - crs

get_band_paths(band_list[, resolution])

Return the paths of required bands.

get_date([as_date])

Get the product's acquisition date.

get_datetime([as_datetime])

Get the product's acquisition datetime, with format YYYYMMDDTHHMMSS <-> %Y%m%dT%H%M%S

get_default_band()

Get default band: GREEN for optical data as every optical satellite has a GREEN band.

get_default_band_path(**kwargs)

Get default band (GREEN for optical data) path.

get_existing_band_paths()

Return the existing band paths.

get_existing_bands()

Return the existing band paths.

get_mean_sun_angles([view])

Get Mean Sun angles (Azimuth and Zenith angles)

has_band(band)

Does this products has the specified band ?

load(bands[, resolution, size])

Open the bands and compute the wanted index.

read_mtd()

Read metadata and outputs the metadata XML root and its namespaces as a dict most of the time, except from L8-collection 1 data which outputs a pandas.DataFrame

stack(bands[, resolution, size, stack_path, ...])

Stack bands and index of a products.

Attributes

crs

Get UTM projection of the tile

extent

Get UTM extent of the tile, managing the case with not orthorectified bands.

footprint

Get UTM footprint in UTM of the products (without nodata, in french == emprise utile)

output

Output directory of the product, to write orthorectified data for example.

clean_tmp()

Clean the temporary directory of the current product

default_transform(**kwargs)

Returns default transform data of the default band (UTM), as the rasterio.warp.calculate_default_transform does: - transform - width - height - crs

Parameters

kwargs – Additional arguments

Returns

transform, width, height

Return type

Affine, int, int

get_band_paths(band_list: list, resolution: Optional[float] = None, **kwargs) dict

Return the paths of required bands.

Warning

If not existing, this function will orthorectify your bands !

>>> from eoreader.reader import Reader
>>> from eoreader.bands.alias import *
>>> path = "S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3"
>>> prod = Reader().open(path)
>>> prod.get_band_paths([GREEN, RED])
Executing processing graph
...11%...21%...31%...42%...52%...62%...73%...83%... done.
{
    <OpticalBandNames.GREEN: 'GREEN'>: '20191115T233722_S3_SLSTR_RBT\S1_reflectance.tif',
    <OpticalBandNames.RED: 'RED'>: '20191115T233722_S3_SLSTR_RBT\S2_reflectance.tif',
}
Parameters
  • band_list (list) – List of the wanted bands

  • resolution (float) – Useless here

  • kwargs – Other arguments used to load bands

Returns

Dictionary containing the path of each queried band

Return type

dict

get_date(as_date: bool = False) Union[str, datetime.date]

Get the product’s acquisition date.

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.get_date(as_date=True)
datetime.datetime(2020, 8, 24, 0, 0)
>>> prod.get_date(as_date=False)
'20200824'
Parameters

as_date (bool) – Return the date as a datetime.date. If false, returns a string.

Returns

Its acquisition date

Return type

str

get_datetime(as_datetime: bool = False) Union[str, datetime.datetime]

Get the product’s acquisition datetime, with format YYYYMMDDTHHMMSS <-> %Y%m%dT%H%M%S

>>> from eoreader.reader import Reader
>>> path = "S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3"
>>> prod = Reader().open(path)
>>> prod.get_datetime(as_datetime=True)
datetime.datetime(2019, 11, 15, 23, 37, 22)
>>> prod.get_datetime(as_datetime=False)
'20191115T233722'
Parameters

as_datetime (bool) – Return the date as a datetime.datetime. If false, returns a string.

Returns

Its acquisition datetime

Return type

Union[str, datetime.datetime]

get_default_band() eoreader.bands.bands.BandNames

Get default band: GREEN for optical data as every optical satellite has a GREEN band.

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.get_default_band()
<OpticalBandNames.GREEN: 'GREEN'>
Returns

Default band

Return type

str

get_default_band_path(**kwargs) Union[cloudpathlib.cloudpath.CloudPath, pathlib.Path]

Get default band (GREEN for optical data) path.

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.get_default_band_path()
'zip+file://S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip!/S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE/GRANULE/L1C_T30TTK_A027018_20200824T111345/IMG_DATA/T30TTK_20200824T110631_B03.jp2'
Parameters

kwargs – Additional arguments

Returns

Default band path

Return type

Union[CloudPath, Path]

get_existing_band_paths() dict

Return the existing band paths.

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.get_existing_band_paths()
{
    <OpticalBandNames.CA: 'COASTAL_AEROSOL'>: 'zip+file://S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip!/S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE/GRANULE/L1C_T30TTK_A027018_20200824T111345/IMG_DATA/T30TTK_20200824T110631_B01.jp2',
    ...,
    <OpticalBandNames.SWIR_2: 'SWIR_2'>: 'zip+file://S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip!/S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE/GRANULE/L1C_T30TTK_A027018_20200824T111345/IMG_DATA/T30TTK_20200824T110631_B12.jp2'
}
Returns

Dictionary containing the path of each queried band

Return type

dict

get_existing_bands() list

Return the existing band paths.

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.get_existing_bands()
[<OpticalBandNames.CA: 'COASTAL_AEROSOL'>,
<OpticalBandNames.BLUE: 'BLUE'>,
<OpticalBandNames.GREEN: 'GREEN'>,
<OpticalBandNames.RED: 'RED'>,
<OpticalBandNames.VRE_1: 'VEGETATION_RED_EDGE_1'>,
<OpticalBandNames.VRE_2: 'VEGETATION_RED_EDGE_2'>,
<OpticalBandNames.VRE_3: 'VEGETATION_RED_EDGE_3'>,
<OpticalBandNames.NIR: 'NIR'>,
<OpticalBandNames.NNIR: 'NARROW_NIR'>,
<OpticalBandNames.WV: 'WATER_VAPOUR'>,
<OpticalBandNames.CIRRUS: 'CIRRUS'>,
<OpticalBandNames.SWIR_1: 'SWIR_1'>,
<OpticalBandNames.SWIR_2: 'SWIR_2'>]
Returns

List of existing bands in the products

Return type

list

get_mean_sun_angles(view: eoreader.products.optical.s3_slstr_product.SlstrView = SlstrView.NADIR) -> (<class 'float'>, <class 'float'>)[source]

Get Mean Sun angles (Azimuth and Zenith angles)

>>> from eoreader.reader import Reader
>>> path = "S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3"
>>> prod = Reader().open(path)
>>> prod.get_mean_sun_angles()
(78.55043955912154, 31.172127033319388)
Parameters

view (SlstrView) – SLSTR View (Nadir or Oblique)

Returns

Mean Azimuth and Zenith angle

Return type

(float, float)

has_band(band: Union[eoreader.bands.bands.BandNames, Callable]) bool

Does this products has the specified band ?

By band, we mean:

  • satellite band

  • index

  • DEM band

  • cloud band

>>> from eoreader.reader import Reader
>>> from eoreader.bands.alias import *
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.has_band(GREEN)
True
>>> prod.has_band(TIR_2)
False
>>> prod.has_band(NDVI)
True
>>> prod.has_band(SHADOWS)
False
>>> prod.has_band(HILLSHADE)
True
Parameters

band (Union[obn, sbn]) – Optical or SAR band

Returns

True if the products has the specified band

Return type

bool

load(bands: Union[list, eoreader.bands.bands.BandNames, Callable], resolution: Optional[float] = None, size: Optional[Union[list, tuple]] = None, **kwargs) dict

Open the bands and compute the wanted index.

The bands will be purged of nodata and invalid pixels, the nodata will be set to 0 and the bands will be masked arrays in float.

Bands that come out this function at the same time are collocated and therefore have the same shapes. This can be broken if you load data separately. Its is best to always load DEM data with some real bands.

>>> from eoreader.reader import Reader
>>> from eoreader.bands.alias import *
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> bands = prod.load([GREEN, NDVI], resolution=20)
>>> bands
{
    <function NDVI at 0x000001EFFFF5DD08>: <xarray.DataArray 'NDVI' (band: 1, y: 5490, x: 5490)>
    array([[[0.949506  , 0.92181516, 0.9279379 , ..., 1.8002278 ,
             1.5424857 , 1.6747767 ],
            [0.95369846, 0.91685396, 0.8957871 , ..., 1.5847116 ,
             1.5248713 , 1.5011379 ],
            [2.9928885 , 1.3031474 , 1.0076253 , ..., 1.5969834 ,
             1.5590671 , 1.5018653 ],
            ...,
            [1.4245619 , 1.6115025 , 1.6201663 , ..., 1.2387121 ,
             1.4025431 , 1.800678  ],
            [1.5627214 , 1.822388  , 1.7245892 , ..., 1.1694248 ,
             1.2573677 , 1.5767351 ],
            [1.653781  , 1.6424649 , 1.5923225 , ..., 1.3072611 ,
             1.2181134 , 1.2478763 ]]], dtype=float32)
    Coordinates:
      * band         (band) int32 1
      * y            (y) float64 4.5e+06 4.5e+06 4.5e+06 ... 4.39e+06 4.39e+06
      * x            (x) float64 2e+05 2e+05 2e+05 ... 3.097e+05 3.098e+05 3.098e+05
        spatial_ref  int32 0,
    <OpticalBandNames.GREEN: 'GREEN'>: <xarray.DataArray (band: 1, y: 5490, x: 5490)>
    array([[[0.0615  , 0.061625, 0.061   , ..., 0.12085 , 0.120225,
             0.113575],
            [0.061075, 0.06045 , 0.06025 , ..., 0.114625, 0.119625,
             0.117625],
            [0.06475 , 0.06145 , 0.060925, ..., 0.111475, 0.114925,
             0.115175],
            ...,
            [0.1516  , 0.14195 , 0.1391  , ..., 0.159975, 0.14145 ,
             0.127075],
            [0.140325, 0.125975, 0.131875, ..., 0.18245 , 0.1565  ,
             0.13015 ],
            [0.133475, 0.1341  , 0.13345 , ..., 0.15565 , 0.170675,
             0.16405 ]]], dtype=float32)
    Coordinates:
      * band         (band) int32 1
      * y            (y) float64 4.5e+06 4.5e+06 4.5e+06 ... 4.39e+06 4.39e+06
      * x            (x) float64 2e+05 2e+05 2e+05 ... 3.097e+05 3.098e+05 3.098e+05
        spatial_ref  int32 0
}
Parameters
  • bands (Union[list, BandNames, Callable]) – Band list

  • resolution (float) – Resolution of the band, in meters

  • size (Union[tuple, list]) – Size of the array (width, height). Not used if resolution is provided.

  • kwargs – Other arguments used to load bands

Returns

{band_name, band xarray}

Return type

dict

read_mtd() Any

Read metadata and outputs the metadata XML root and its namespaces as a dict most of the time, except from L8-collection 1 data which outputs a pandas.DataFrame

>>> from eoreader.reader import Reader
>>> path = r"S1A_IW_GRDH_1SDV_20191215T060906_20191215T060931_030355_0378F7_3696.zip"
>>> prod = Reader().open(path)
>>> prod.read_mtd()
(<Element product at 0x1832895d788>, '')
Returns

Metadata XML root and its namespace or pd.DataFrame

Return type

Any

stack(bands: list, resolution: Optional[float] = None, size: Optional[Union[list, tuple]] = None, stack_path: Optional[Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path]] = None, save_as_int: bool = False, **kwargs) xarray.core.dataarray.DataArray

Stack bands and index of a products.

>>> from eoreader.reader import Reader
>>> from eoreader.bands.alias import *
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> stack = prod.stack([NDVI, MNDWI, GREEN], resolution=20)  # In meters
>>> stack
<xarray.DataArray 'NDVI_MNDWI_GREEN' (z: 3, y: 5490, x: 5490)>
array([[[ 0.949506  ,  0.92181516,  0.9279379 , ...,  1.8002278 ,
          1.5424857 ,  1.6747767 ],
        [ 0.95369846,  0.91685396,  0.8957871 , ...,  1.5847116 ,
          1.5248713 ,  1.5011379 ],
        [ 2.9928885 ,  1.3031474 ,  1.0076253 , ...,  1.5969834 ,
          1.5590671 ,  1.5018653 ],
        ...,
        [ 1.4245619 ,  1.6115025 ,  1.6201663 , ...,  1.2387121 ,
          1.4025431 ,  1.800678  ],
        [ 1.5627214 ,  1.822388  ,  1.7245892 , ...,  1.1694248 ,
          1.2573677 ,  1.5767351 ],
        [ 1.653781  ,  1.6424649 ,  1.5923225 , ...,  1.3072611 ,
          1.2181134 ,  1.2478763 ]],
       [[ 0.27066118,  0.23466069,  0.18792598, ..., -0.4611526 ,
         -0.49751845, -0.4865216 ],
        [ 0.22425456,  0.28004232,  0.27851456, ..., -0.5032771 ,
         -0.501796  , -0.502669  ],
        [-0.07466951,  0.06360884,  0.1207174 , ..., -0.50617427,
         -0.50219285, -0.5034222 ],
        [-0.47076276, -0.4705828 , -0.4747971 , ..., -0.32138503,
         -0.36619243, -0.37428448],
        [-0.4826967 , -0.5032287 , -0.48544118, ..., -0.278925  ,
         -0.31404778, -0.36052078],
        [-0.488381  , -0.48253912, -0.4697526 , ..., -0.38105175,
         -0.30813277, -0.27739233]],
       [[ 0.0615    ,  0.061625  ,  0.061     , ...,  0.12085   ,
          0.120225  ,  0.113575  ],
        [ 0.061075  ,  0.06045   ,  0.06025   , ...,  0.114625  ,
          0.119625  ,  0.117625  ],
        [ 0.06475   ,  0.06145   ,  0.060925  , ...,  0.111475  ,
          0.114925  ,  0.115175  ],
        ...,
        [ 0.1516    ,  0.14195   ,  0.1391    , ...,  0.159975  ,
          0.14145   ,  0.127075  ],
        [ 0.140325  ,  0.125975  ,  0.131875  , ...,  0.18245   ,
          0.1565    ,  0.13015   ],
        [ 0.133475  ,  0.1341    ,  0.13345   , ...,  0.15565   ,
          0.170675  ,  0.16405   ]]], dtype=float32)
Coordinates:
  * y            (y) float64 4.5e+06 4.5e+06 4.5e+06 ... 4.39e+06 4.39e+06
  * x            (x) float64 2e+05 2e+05 2e+05 ... 3.097e+05 3.098e+05 3.098e+05
    spatial_ref  int32 0
  * z            (z) MultiIndex
  - variable     (z) object 'NDVI' 'MNDWI' 'GREEN'
  - band         (z) int64 1 1 1
-Attributes:
    long_name:  ['NDVI', 'MNDWI', 'GREEN']
Parameters
  • bands (list) – Bands and index combination

  • resolution (float) – Stack resolution. . If not specified, use the product resolution.

  • size (Union[tuple, list]) – Size of the array (width, height). Not used if resolution is provided.

  • stack_path (Union[str, CloudPath, Path]) – Stack path

  • save_as_int (bool) – Convert stack to uint16 to save disk space (and therefore multiply the values by 10.000)

  • **kwargs – Other arguments passed to load or rioxarray.to_raster() (such as compress)

Returns

Stack as a DataArray

Return type

xr.DataArray

archive_path

Archive path, same as the product path if not specified. Useful when you want to know where both the extracted and archived version of your product are stored.

band_names

Band mapping between band wrapping names such as GREEN and band real number such as 03 for Sentinel-2.

condensed_name

Condensed name, the filename with only useful data to keep the name unique (ie. 20191215T110441_S2_30TXP_L2A_122756). Used to shorten names and paths.

corresponding_ref

The corresponding reference products to the current one (if the product is not a reference but has a reference data corresponding to it). A list because of multiple ref in case of non-stackable products (S3, S1…)

property crs: rasterio.crs.CRS

Get UTM projection of the tile

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.crs
CRS.from_epsg(32630)
Returns

CRS object

Return type

rasterio.crs.CRS

date

Acquisition date.

datetime

Acquisition datetime.

property extent: geopandas.geodataframe.GeoDataFrame

Get UTM extent of the tile, managing the case with not orthorectified bands.

>>> from eoreader.reader import Reader
>>> path = "S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3"
>>> prod = Reader().open(path)
>>> prod.utm_extent()
                                            geometry
0  POLYGON ((1488846.028 6121896.451, 1488846.028...
Returns

Footprint in UTM

Return type

gpd.GeoDataFrame

property footprint: geopandas.geodataframe.GeoDataFrame

Get UTM footprint in UTM of the products (without nodata, in french == emprise utile)

>>> from eoreader.reader import Reader
>>> path = r"S2A_MSIL1C_20200824T110631_N0209_R137_T30TTK_20200824T150432.SAFE.zip"
>>> prod = Reader().open(path)
>>> prod.footprint
   index                                           geometry
0      0  POLYGON ((199980.000 4500000.000, 199980.000 4...
Returns

Footprint as a GeoDataFrame

Return type

gpd.GeoDataFrame

is_archived

Is the archived product is processed (a products is considered as archived if its products path is a directory).

is_reference

If the product is a reference, used for algorithms that need pre and post data, such as fire detection.

name

Product name (its filename without any extension).

needs_extraction

Does this products needs to be extracted to be processed ? (True by default).

nodata

Product nodata, set to -999 by default

property output: Union[cloudpathlib.cloudpath.CloudPath, pathlib.Path]

Output directory of the product, to write orthorectified data for example.

path

Usable path to the product, either extracted or archived path, according to the satellite.

platform

Product platform, such as Sentinel-2

product_type

Type of this product (i.e. L2A or SLC)

resolution

Default resolution in meters of the current product. For SAR product, we use Ground Range resolution as we will automatically orthorectify the tiles.

sat_id

Satellite ID, i.e. S2 for Sentinel-2

sensor_type

Sensor type, SAR or optical.

split_name

Split name, to retrieve every information from its filename (dates, tile, product type…). WARNING: Use it with caution as EOReader accepts products with modified names !

tile_name

Tile if possible (for data that can be piled, for example S2 and Landsats).