Copernicus Data Space Ecosystem (CDSE) Class

class terragon.copernicus_data_space_ecosystem.CDSE(credentials, base_url='https://catalogue.dataspace.copernicus.eu/stac/', end_point_url='https://eodata.dataspace.copernicus.eu')

Bases: Base

Class to interact with the Copernicus Data Space Ecosystem. The images are downloaded from the AWS bucket. The packages rasterio/rioxarray/boto will be used to download the images. Currently only these collections are supported: COP-DEM, GLOBAL-MOSAICS, LANDSAT-5, LANDSAT-7, LANDSAT-8-ESA, TERRAAQUA, S2GLC, SENTINEL-1, SENTINEL-1-RTC, SENTINEL-2.

Parameters:
  • credentials (dict) – credentials to authenticate, expected format: {‘aws_access_key_id’: <id>, ‘aws_secret_access_key’: <key>}. If None, it will fallback to the credential handling from boto3/rasterio.

  • base_url (str) – the URL for the STAC catalog, defaults to “https://catalogue.dataspace.copernicus.eu/stac/

  • end_point_url (str) – the URL for the data endpoint, defaults to “https://eodata.dataspace.copernicus.eu

download(items)

Download the items from the Copernicus Data Space Ecosystem and pack them to a xarray.Dataset or download the files and return the file paths.

Parameters:

items – items to download

Returns:

xarray.Dataset or list of filenames

retrieve_collections(query={}, fields=[])

Search the collections provided by Copernicus Data Space Ecosystem.

Parameters:
  • query (dict) – query to filter the collections for in style ‘{<key>:<regex>}’, defaults to {}

  • fields (list[str]) – list of fields to include in the response, defaults to []

Return type:

list

Returns:

a list of dictionaries with collection metadata

search(*args, resampling=Resampling.nearest, use_virtual_rasterio_file=True, rm_tmp_files=True, filter_asset_path={'COP-DEM': '.*/DEM/.*', 'SENTINEL-2': '.*/IMG_DATA/.*'}, **kwargs)

Search for items in the Copernicus Data Space Ecosystem collections via stac, return the items and their meta data, and store the parameters in the class in order to access them later in the download function. For a description of the args/kwargs parameters see the Base class function.

Parameters:
  • resampling – rasterio Resampling method is used to reproject the cubes, defaults to rasterio.enums.Resampling.nearest

  • use_virtual_rasterio_file – use rasterio virtual file function when True, when False whole file is downloaded, defaults to True

  • rm_tmp_files – only used with ‘use_virtual_rasterio_file=False’ to remove the files after the minicube is created, defaults to True

  • filter_asset_path – manual filtering of the filepath in the AWS bucket, used for collections with ambiguous file names, defaults to {“COP-DEM”: “.*/DEM/.*”, “SENTINEL-2”: “.*/IMG_DATA/.*”}

  • args/kwargs – Parameters which are handled by the parent class, these parameters are the same for all data providers. See the ‘Base’ class for more information.

Raises:
  • ValueError – when no items are found or parameters are in the wrong format

  • RuntimeError – when the corresponding files for the items are not found

Returns:

a list of items