While eodag ‘s main goal is to offer an easy way to search and download EO products, it doesn’t want to be a dead-end to the users who would like to post-process the products they have downloaded.
The download methods all return the local path of each product downloaded. Theses paths can be fed into another program for further processing. See for instance the tutorial that makes use of SNAP to detect ships on Sentinel 1 images.
Note
The file paths returned (strings) are in the file URI format (e.g. file:///tmp on Linux). You may need in some occasions to remove the file:// prefix.
Sentinel products are generally distributed in the SAFE format. AWS-based providers however offers Sentinel products in a “scattered” way, each file being able to be downloaded individually. eodag downloads these multiple files and automatically builds a SAFE product out of them. Image processing softwares such as SNAP work well with products in the SAFE format.
At some point eodag had some capabilities to directly post-process a product, i.e. to access its data. These capabilities, which relied on xarray and rasterio, have been ported to the Python package eodag-cube to avoid the heavy dependencies associated with rasterio and GDAL in particular. Installing this package is enough to benefit from its
capabilities.
eodag-cube extends the EOProduct class with a to_xarray() method which returns product readable content in a XarrayDict (dictionary of xarray.Dataset). A ffspec file refering to the data can also be obtained using the
get_file_obj() method.
In this example, a search is made to get Sentinel 2 Level-1C products from Creodias S3.
Warning
eodag-cube needs to be installed to run correcly the following code.
[1]:
# Set the credentials with environment variablesimportosos.environ["EODAG__CREODIAS_S3__AUTH__CREDENTIALS__AWS_ACCESS_KEY_ID"]="PLEASE_CHANGE_ME"os.environ["EODAG__CREODIAS_S3__AUTH__CREDENTIALS__AWS_SECRET_ACCESS_KEY"]="PLEASE_CHANGE_ME"fromeodagimportEODataAccessGatewaydag=EODataAccessGateway()# Define the search criteria and search for productssearch_criteria={"provider":"creodias_s3","productType":"S2_MSI_L1C","start":"2023-06-01","end":"2023-06-30","geom":{"lonmin":1.306,"latmin":43.527,"lonmax":1.551,"latmax":43.662},"cloudCover":1# Cloud cover < 1}products=dag.search(**search_criteria)product=products[0]product
'The Level-1C product is composed of 100x100 km2 tiles (ortho-images in UTM/WGS84 projection). It results from
using a Digital Elevation Model (DEM) to project the image in cartographic geometry. Per-pixel radiometric
measurements are provided in Top Of Atmosphere (TOA) reflectances along with the parameters to transform them
into radiances. Level-1C products are resampled with a constant Ground Sampling Distance (GSD) of 10, 20 and 60
meters depending on the native resolution of the different spectral bands. In Level-1C products, pixel
coordinates refer to the upper left corner of the pixel. Level-1C products will additionally include Cloud Masks
and ECMWF data (total column of ozone, total column of water vapour and mean sea level pressure).
SAFE formatted product, see https://sentinel.esa.int/web/sentinel/user-guides/sentinel-2-msi/data-formats
',
<xarray.Dataset> Size: 126kB
Dimensions: (x: 216, y: 142, band: 1)
Coordinates:
* x (x) float64 2kB 1.435 1.435 1.435 1.435 ... 1.458 1.458 1.458
* y (y) float64 1kB 43.6 43.6 43.6 43.6 ... 43.59 43.59 43.59 43.59
* band (band) int64 8B 1
spatial_ref int64 8B 0
Data variables:
band_data (band, y, x) float32 123kB nan nan nan nan ... nan nan nan nan