Mosaic#

class Mosaic(paths: list | str | CloudPath | Path, output_path: str | CloudPath | Path | None = None, id: str | None = None, remove_tmp: bool = True, contiguity_check: GeometryCheck | str = GeometryCheck.EXTENT, mosaic_method: MosaicMethod | str = MosaicMethod.VRT, **kwargs)[source]#

Bases: Set

Class of mosaic objetcs, composed of several contiguous EOReader’s products acquired the same day.

__init__(paths: list | str | CloudPath | Path, output_path: str | CloudPath | Path | None = None, id: str | None = None, remove_tmp: bool = True, contiguity_check: GeometryCheck | str = GeometryCheck.EXTENT, mosaic_method: MosaicMethod | str = MosaicMethod.VRT, **kwargs)[source]#

Output path of the pairs.

check_compatibility(first_prod: Product, prod: Product) None[source]#

Check if the mosaic products are coherent between each other. - Same sensor type - Same date

TODO: same constellation ?

If not, throws a IncompatibleProducts error.

Parameters:
  • first_prod (Product) – First product, to be checked against

  • prod (Product) – Product to check

Raises:

IncompatibleProducts – Incompatible products if not contiguous or not the same date

check_contiguity(check_contiguity: GeometryCheck)[source]#

Check the contiguity of the mosaic

Parameters:

check_contiguity (GeometryCheck) – Contiguity checking method

Raises:

IncompatibleProducts – Incompatible products if not contiguous according to the given method

clean_tmp()[source]#

Clean the temporary directory of the current mosaic

clear()[source]#

Clear this mosaic’s cache

condensed_name#

Mosaic condensed name, a mix based on the dates and constellations of the components of the mosaic.

constellations#

List of unique constellations constituting the set

crs#

CRS of the mosaic. If not provided in kwargs, using the first product’s crs.

date#

Date of the mosaic. If not provided in kwargs, using the first product’s date.

datetime#

Datetime of the mosaic. If not provided in kwargs, using the first product’s datetime.

extent = <methodtools._LruCacheWire object>[source]#
footprint = <methodtools._LruCacheWire object>[source]#
full_name: str#

Mosaic full name.

get_attr(attr: str, **kwargs) Any#

Get attribute, either from kwargs or from the first product (default)

Parameters:
  • attr (str) – Wanted attribute

  • **kwargs – Other args

Returns:

Attribute result

Return type:

Any

get_bands_to_load(bands, out_suffix='tif') -> (<class 'list'>, <class 'dict'>)#
get_first_prod() Product#

Get first product, which should be coherent with all others

Returns:

First reference product

Return type:

Product

get_prods() list[source]#

Get all the products as a list.

Returns:

Products list

Return type:

list

has_band(band: BandNames | str) bool#

Does this moasic have products with the specified band ?

By band, we mean:

  • satellite band

  • index

  • DEM band

  • cloud band

Parameters:

band (Union[BandNames, str]) – EOReader band (optical, SAR, clouds, DEM)

Returns:

True if the products has the specified band

Return type:

bool

has_bands(bands: list | BandNames | str) bool#

Does this moasic have products with the specified bands ?

By band, we mean:

  • satellite band

  • index

  • DEM band

  • cloud band

See has_band for a code example.

Parameters:

bands (Union[list, BandNames, str]) – EOReader bands (optical, SAR, clouds, DEM)

Returns:

True if the products has the specified band

Return type:

bool

id: str#

ID of the reference product, given by the creator of the mosaic. If not, a mix based on the dates and constellations of its components.

is_homogeneous(attr: str) bool#

Check if the given attribute is the same for all products constituting the mosaic.

Parameters:

attr (str) – Attribute to be checked. Must be available in EOReader’s Product

Returns:

True if this attribute is the same for all products constituting the mosaic.

Return type:

bool

load(bands: list | BandNames | str, pixel_size: float | None = None, **kwargs) Dataset[source]#

Load the bands and compute the wanted spectral indices.

Parameters:
  • bands (Union[list, BandNames, str]) – Wanted bands

  • pixel_size (float) – Pixel size of the returned Dataset. If not specified, use the mosaic’s pixel size.

  • **kwargs – Other arguments used to load bands

Returns:

Wanted bands as xr.Datasets

Return type:

xr.Dataset

mosaic_method#

Mosaicing method. If GTIFF is specified, the temporary files from every products will be removed, if VRT is spoecified, they will not.

nodata#

Nodata of the mosaic. If not provided in kwargs, using the first product’s nodata.

nof_prods: int#

Number of products.

property output: CloudPath | Path#

Output directory of the set

Returns:

Output path of the set

Return type:

AnyPathType

pixel_size#

Pixel size of the set. If not provided in kwargs, using the first product’s pixel size.

prods: dict#

Products (contiguous and acquired the same day).

read_mtd()[source]#

Read the pair’s metadata, but not implemented for now.

same_constellation: bool#

Is the mosaic constituted of the same constellation?

same_crs: bool#

Is the mosaic constituted of the same sensor type?

stack(bands: list, pixel_size: float | None = None, stack_path: str | CloudPath | Path | None = None, save_as_int: bool = False, **kwargs) DataArray[source]#

Stack bands and index of a mosaic.

Parameters:
  • bands (list) – Bands and index combination

  • pixel_size (float) – Stack pixel size. . If not specified, use the product pixel size.

  • stack_path (Union[str, AnyPathType]) – 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