Assets#

class eodag.api.product._assets.AssetsDict(product, *args, **kwargs)[source]#

A UserDict object which values are Asset contained in a EOProduct resulting from a search.

Parameters:
  • product (EOProduct) – Product resulting from a search

  • args (Any) – (optional) Arguments used to init the dictionary

  • kwargs (Any) – (optional) Additional named-arguments used to init the dictionary

Example#

>>> from eodag.api.product import EOProduct
>>> product = EOProduct(
...     provider="foo",
...     properties={"id": "bar", "geometry": "POINT (0 0)"}
... )
>>> type(product.assets)
<class 'eodag.api.product._assets.AssetsDict'>
>>> product.assets.update({"foo": {"href": "http://somewhere/something"}})
>>> product.assets
{'foo': {'href': 'http://somewhere/something'}}
as_dict()[source]#

Builds a representation of AssetsDict to enable its serialization

Return type:

dict[str, Any]

Returns:

The representation of a AssetsDict as a Python dict

get_values(asset_filter='', regex=True)[source]#

retrieves the assets matching the given filter

Parameters:
  • asset_filter (str, default: '') – regex filter with which the assets should be matched

  • regex (default: True) – Uses regex to match the asset key or simply compare strings

Return type:

list[Asset]

Returns:

list of assets

class eodag.api.product._assets.Asset(product, key, *args, **kwargs)[source]#

A UserDict object containg one of the assets resulting from a search.

Parameters:
  • product (EOProduct) – Product resulting from a search

  • key (str) – asset key

  • args (Any) – (optional) Arguments used to init the dictionary

  • kwargs (Any) – (optional) Additional named-arguments used to init the dictionary

Example#

>>> from eodag.api.product import EOProduct
>>> product = EOProduct(
...     provider="foo",
...     properties={"id": "bar", "geometry": "POINT (0 0)"}
... )
>>> product.assets.update({"foo": {"href": "http://somewhere/something"}})
>>> type(product.assets["foo"])
<class 'eodag.api.product._assets.Asset'>
>>> product.assets["foo"]
{'href': 'http://somewhere/something'}
as_dict()[source]#

Builds a representation of Asset to enable its serialization

Return type:

dict[str, Any]

Returns:

The representation of a Asset as a Python dict

download(**kwargs)[source]#

Downloads a single asset

Parameters:

kwargs (Unpack[DownloadConf]) – (optional) Additional named-arguments passed to plugin.download()

Return type:

str

Returns:

The absolute path to the downloaded product on the local filesystem

Pixel access#

Warning

The following methods will only be available with eodag-cube installed.

class eodag_cube.api.product._assets.AssetsDict#

Inherits from eodag.api.product._assets.AssetsDict and implements pixel access related methods.

class eodag_cube.api.product._assets.Asset#

Inherits from eodag.api.product._assets.Asset and implements pixel access related methods.

Asset.to_xarray(wait=0.2, timeout=10, **xarray_kwargs)[source]#

Return asset data as a xarray.Dataset.

Parameters:
  • wait (float, default: 0.2) – (optional) If order is needed, wait time in minutes between two order status check

  • timeout (float, default: 10) – (optional) If order is needed, maximum time in minutes before stop checking order status

  • xarray_kwargs (Any) – (optional) keyword arguments passed to xarray.open_dataset()

Return type:

Dataset

Returns:

Asset data as a xarray.Dataset

Asset.get_file_obj(wait=0.2, timeout=10)[source]#

Open asset data using fsspec

Parameters:
  • wait (float, default: 0.2) – (optional) If order is needed, wait time in minutes between two order status check

  • timeout (float, default: 10) – (optional) If order is needed, maximum time in minutes before stop checking order status

Return type:

OpenFile

Returns:

asset data file object

Asset.rio_env()[source]#

Get rasterio environment

Return type:

Env | nullcontext

Returns:

The rasterio environment

Asset.get_data(crs=None, resolution=None, extent=None, resampling=None, **rioxr_kwargs)[source]#

Retrieves asset raster data abstracted by the eodag.api.product._product.EOProduct

Parameters:
  • crs (str | None, default: None) – (optional) The coordinate reference system in which the dataset should be returned

  • resolution (float | None, default: None) – (optional) The resolution in which the dataset should be returned (given in the unit of the crs)

  • extent (str | Dict[str, float] | List[float] | BaseGeometry | None, default: None) –

    (optional) The coordinates on which to zoom, matching the given CRS. Can be defined in different ways (its bounds will be used):

    • with a Shapely geometry object: shapely.geometry.base.BaseGeometry

    • with a bounding box (dict with keys: “lonmin”, “latmin”, “lonmax”, “latmax”): dict.fromkeys(["lonmin", "latmin", "lonmax", "latmax"])

    • with a bounding box as list of float: [lonmin, latmin, lonmax, latmax]

    • with a WKT str

  • resampling (Resampling | None, default: None) – (optional) Warp resampling algorithm passed to rasterio.vrt.WarpedVRT

  • rioxr_kwargs (Any) – kwargs passed to rioxarray.open_rasterio()

Return type:

DataArray

Returns:

The numeric matrix corresponding to the sub dataset or an empty array if unable to get the data

Deprecated since version 0.6.0b1: Use the eodag_cube.api.product._assets.Asset.to_xarray() method instead.