Zarr Import API examples

The following API requests are written in Python. To execute them, you need to create an OAuth client as is explained here. The client is named oauth in these examples. The examples are structured in a way to be as separable as possible, however in many cases doing all the steps in each chapter makes sense.

Creating a collection

To create a collection with the name My Collection and S3 bucket my-bucket using Zarr data that resides inside s3://my-bucket/path-to-zarr.zarr/:

collection = {
'name': 'My Collection',
's3Bucket': 'my-bucket',
'path': 'path-to-zarr.zarr/',
"crs":"http://www.opengis.net/def/crs/EPSG/0/4326"
}
response = oauth.post('https://services.sentinel-hub.com/api/v1/zarr/collections', json=collection)
response.raise_for_status()

Extracting the collection id and status from the response:

collection = response.json()['data']
collection_id = collection['id']
collection_status = collection['status']
# if the ingestion failed, you can access the error as follows:
# collection_errors = collection['ingestionErrors']

To update the name of your Zarr collection:

# Update name of the collection
new_col_name = {
name: 'My modified collection name'
}
response = oauth.put(f'https://services.sentinel-hub.com/api/v1/zarr/collections/{collection_id}', json=new_col_name)
response.raise_for_status()

To delete the collection:

# Delete the collection
response = oauth.delete(f'https://services.sentinel-hub.com/api/v1/zarr/collections/{collection_id}')
response.raise_for_status()

Listing arrays

If the ingestion was successful, you can query all ingested arrays and their properties. Arrays are paginated, that is, if there are more than 100 arrays you will only get the first 100 by default. All pages can be traversed in the same way as with other paged Sentinel Hub endpoints (see e.g. the example under listing tiles on BYOC). Retrieving the first page is shown in the following snippet:

response = oauth.get(f'https://services.sentinel-hub.com/api/v1/zarr/collections/{collection_id}/arrays')
response.raise_for_status()
arrays = response.json()['data']

You can also get a single array by adding the array name to the URL path. For example, to get the array named B1 of the above collection:

b1_array_response = oauth.get(f'https://services.sentinel-hub.com/api/v1/zarr/collections/{collection_id}/arrays/B1')
b1_array_response.raise_for_status()
b1_array = b1_array_response.json()['data']