Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Accessing External Data - CDSE - Sentinel-2

ESA

Accessing CDSE Data with the Pangeo Stack

Start a cluster

AOE: Almería coast, southern Spain

A smaller coastal box near Almería, chosen inside a single Sentinel-2 tile.

<Figure size 800x500 with 1 Axes>

S3 Credentials

taken from: https://documentation.dataspace.copernicus.eu/notebook-samples/geo/stac_ndvi.html

In order to access the data from CloudFerro’s catalog, authentication is required. To facilitate this, you will need to create an account in the Copernicus Data Space Ecosystem (CDSE). The registration process is quick and can be completed in under 60 seconds. You can find the registration link here: https://documentation.dataspace.copernicus.eu/APIs/S3.html.

Once you have created an account, the same URL will redirect you to the section where you can generate your S3 Credentials. To do this, simply click the Add Credential button. This will allow you to define an expiration date for your credentials.

After selecting the expiration date, you will have successfully created your own S3 credentials. Please make sure to save the secret key at this point, as it will not be displayed again.

Now that you have your S3 credentials, you can use them to connect to the STAC catalog. By utilizing the os package, you will set environment variables to authenticate yourself as a valid user for the S3 protocol.

The only variables you need to configure are:

  • CDSE_S3_ACCESS_KEY

  • CDSE_S3_SECRET_KEY.

Connecting to the STAC Catalog

We connect to the Copernicus STAC catalog, available at the endpoint: https://stac.dataspace.copernicus.eu/v1.

Open the daily cube for this area

Loading...

Select six scenes

Take the six least cloudy scenes for this smaller box in July–August 2017.

Creating DataCube from STAC

After performing the search, we can create a STACK object from the obtained items. In the definition of the STACK object, the following parameters must be declared:

  • items: The STAC items that will be included in the stack object.

  • resolution: The desired output resolution.

  • bounds_latlon: The spatial bounding box of the output, given in degrees of latitude and longitude.

  • chunksize: The chunk size to be used for the Dask array.

  • epsg: The EPSG code for the coordinate reference system to which the data will be reprojected.

  • gdal_env: GDAL configuration options to be used when opening and reading the datasets.

note: added a workaround for compatibility reasons

<xarray.plot.facetgrid.FacetGrid at 0x1774e52b0>
<Figure size 1000x1200 with 12 Axes>

Overlay the first displayed date and salinity

<Figure size 900x600 with 2 Axes>

Compare NDCI and salinity over time

NDCI (Normalized Difference Chlorophyll Index) uses red-edge and red reflectance:

NDCI = (B05 - B04) / (B05 + B04)

Compare its daily mean with salinity (sos) over the same ocean pixels. NDCI is a relative chlorophyll-sensitive index, not chlorophyll concentration; it was developed for productive, turbid coastal waters and is less informative in clear, low-chlorophyll water (original paper).

Loading...
Loading...
Loading...
<Figure size 900x500 with 2 Axes>

Network request benchmark

Computing close to the data can make downloads much faster.

Close to the data on the cloud

Running on a small machine with 2 GB RAM near the data storage:

SourceDownloadedWall timeTotal CPU time
CDSE Sentinel-2117 MiB1.96 s570 ms
EarthCODE cube (CloudFerro)102 MiB1.21 s449 ms

Running locally

Running the same benchmark locally over a reasonably fast internet connection:

SourceWall timeTotal CPU time
CDSE Sentinel-211.2 s598 ms
EarthCODE cube (CloudFerro)12.1 s578 ms

In this run, downloading close to the data was approximately 6× faster for CDSE and 10× faster for the cube.

Wall time is the elapsed time you wait. CPU time measures processor work, excluding time spent waiting for the network.

References
  1. Mishra, S., & Mishra, D. R. (2012). Normalized difference chlorophyll index: A novel model for remote estimation of chlorophyll-a concentration in turbid productive waters. Remote Sensing of Environment, 117, 394–406. 10.1016/j.rse.2011.10.016