Assets#

The Assets module provides classes and methods to manage and interact with assets associated with EOProduct. These assets can include files, metadata, or other resources that are part of a product’s data package. The module offers functionality for accessing, manipulating, and extending asset-related operations.

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

update(data)[source]#

Update assets

Parameters:

data (dict[str, Any])

Return type:

None

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

stream_download(**kwargs)[source]#

Downloads a single asset as StreamResponse

Parameters:

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

Return type:

StreamResponse

Returns:

StreamResponse stream representation of the asset file

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