C-scale data discovery

The EO-MQS service is hosted within the C-SCALE federated cloud infrastructure and provides a unified way of discovering Copernicus data available within the federation by making use of the SpatioTemporal Asset Catalog (STAC) specification. The purpose of this notebook is to provide a concise introduction on how to use open-source Python libraries to search for geospatial data exposed by the EO-MQS STAC API.
Prerequisites
In this example, we are going to make use of a popular STAC client for Python, the pystac-client
. The library can be manually installed anywhere else via pip install pystac-client
. Alternatively, common Python libraries like the requests
library which support working with HTTP APIs are of course also well suited.
To get started, we need to import the Client
class to connect to the EO-MQS which exposes its STAC API under https://mqs.eodc.eu/stac/v1.
We need to import Python libraries and some useful functions as well.
CollectionClient
The client can be used to iterate through the Collections available in the EO-MQS Catalog.
The get_collections
method fetches the collections from the /collections
endpoint and returns an iterable. To load a particular collection for further use we call the get_collection(<collection_id>)
method below.
On static as well as dynamic catalogues we can also make use of the links attributes which lets us quickly explore, for instance, the number of available collections.
We can also check the details of particular collection.
We can use of some useful ways how to access collection metadata programmatically.
STAC Items
Data providers that have realized their STAC implementation in terms of a dynamic STAC API offer users the opportunity to search their Catalogs using spatial and temporal constraints. The pystac_client
enables this search via the class method search. This function returns an ItemSearch instance that can further be accessed to retrieve matched items.
Note that in its current implementation, the EO-MQS supports the core STAC search endpoint parameters as described in the STAC API - Item Search specification. Those are:
- limit
- bbox
- datetime
- intersects
- ids
- collections
Visualize Sentinel-2 data over EU
We can use the geojson file created using geojson.io.
Choosing the time interval and limit for the search.
As before, we can use the collection client instance to iterate over the items contained in the collection. The server must provide the /collections/<collection_id>/items
endpoint to support this feature automatically. This can be useful to manually filter items or extract information programmatically. The get_all_items()
method again returns an iterator.
We can check time interval of each collection.
We can search for the collections that contain satellite images of EU region.
Item Search
Search for Sentinel-2 data intersecting a GeoJSON object
This first example makes use of the intersects
and the collections
parameters. Note that you cannot specify both bbox and intersects
, this will result in an error.
For this example we can use region around the city of Utrecht.
We can have a look on one item that has been found in the search.
We can download a preview image of the satellite image.
NOTE: You can always visualize STAC data (collections, items, etc.) in external tools like the STAC Browser, for instance do the following:
Search for Sentinel-2 data using bbox
The second example makes use of the bbox
, datetime
and the collections
parameters. Learn about the correct formatting of these values on the STAC Spec GitHub page or by looking at the pystac-client docs.
This time we will convert geojson file into bbox coordinates.
We can put together all collections that contains desired region.
We can plot some parameters that are stored within these collections, e.g. cloud coverage over the selected area.
We can see the results just directly printed.
We can plot the search results which is more convenient.
Cloudless search
Let’s now focus on downloading particular region of interest with almost zero cloud coverage.
Find the lowest cloud coverage in the collection of the desired region of interest.
We can find dates of cloudless days.
We can choose exact day we would like to download and visualize this particular satellite tile in the map and check its geographical position as well as the shape.
Saving image coordinates for later
Downloading images
We can check the metadata in the browser.
For downloading data, we need the URL and ACCESS TOKEN, which is ready in the notebook since logon. We can load it and check user info.
We can check attributes. For convenience and to maintain privacy we will filter for those relevant to C-SCALE.
Now we can download all the data we need from the collection and save it.
For later analysis we might need some/all spectral bands that is provided together with RGB image.
We can see the satellite image tile with its original size and quality but it takes roughly 4 min!
Last updated on