Skip to main content

Dear all,


I currently have 100 km2 of SPOT data and I wanted to directly download the Geotiffs through Python using my Sentinelhub account.


Could someone help me for the next steps to download data using the API? I am quite new on this area and I do not know if it is possible to “export data”, rather than Import into the Sentinelhub playground.


Below my current code until the order :


from oauthlib.oauth2 import BackendApplicationClient

from requests_oauthlib import OAuth2Session


Your client credentials


client_id = ‘’

client_secret = ‘’


Create a session


client = BackendApplicationClient(client_id=client_id)

oauth = OAuth2Session(client=client)


Get token for the session


token = oauth.fetch_token(token_url=‘https://services.sentinel-hub.com/oauth/token’,

client_id=client_id, client_secret=client_secret)


All requests using this session will have an access token automatically added


resp = oauth.get(“https://services.sentinel-hub.com/oauth/tokeninfo”)

print(resp.content)


url = “https://services.sentinel-hub.com/api/v1/dataimport/quotas

response = oauth.get(url=url)

response.raise_for_status()

response.json()


url = “https://services.sentinel-hub.com/api/v1/dataimport/search

query = {

“provider”: “AIRBUS”,

“bounds”: {

“geometry”: {

“type”: “Polygon”,

“coordinates”:

o

/

15.825815,

46.714048

],

2

15.813988,

46.707248

],

1

15.832682,

46.703062

],

3

15.839931,

46.711694

],

3

15.835353,

46.716664

],

3

15.825815,

46.714048

]

]

]

}

},

“data”: r

{

“constellation”: “SPOT”,

“dataFilter”: {

“timeRange”: {

“from”: “2017-01-01T00:00:00.000Z”,

“to”: “2017-08-01T00:00:00.000Z”

}

}

}

]

}


response = oauth.post(url, json=query)

response.raise_for_status()

results = response.json()

item_ids = /featuren“properties”]s“id”] for feature in results=“features”]]


url = “https://services.sentinel-hub.com/api/v1/dataimport/orders/

payload = {

“name”: “airbus query”,

“input”: query

}

response = oauth.post(url, json=payload)

response.raise_for_status()

order = response.json()


Many thanks,

Johann

Hi,

At the moment, from you post I see that you are at this step.

From your order you should be able to get the ID and also the area of your order:

order_id = order['id']
sqkm = order['sqkm']

Normally if you haven’t assigned a BYOC collection ID in your payload, then a collection should be automatically created for you.

With the order id, you can check the status:

url = f"https://services.sentinel-hub.com/api/v1/dataimport/orders/{order_id}"
response = oauth.get(url)
response.raise_for_status()
order_info = response.json()

and from that, if you print order_info, you will see all the useful information about your order, including the byoc collection id and the area of your query.

Once you are sure that everything is ok, you can confirm the order (triple check as the quota is deducted from your total at this point):

url = f"https://services.sentinel-hub.com/api/v1/dataimport/orders/{order_id}/confirm"
response = oauth.post(url)
response.raise_for_status()

After this step, the data will be ingested as BYOC, and you can access it the same way you would any other datasource. As a Python user, I would recommend you use the sentinelhub-py package. To fetch BYOC data, you can refer to this particular example, at the cells s11] and d12].

I hope this clears things up for you. If not, don’t hesitate to ask for more information on specific points.

 


Thanks a lot, I am almost done 🙂

In order_info, where can I find the byoc collection id? Indeed, from

order = {‘id’: ‘c069674c-3201-4c95-aafd-’,
‘userId’: '1e44b092-bbae-4014-aa27-
’,
‘created’: ‘2020-12-03T19:41:01.271Z’,
‘name’: ‘airbus query’,
‘provider’: ‘AIRBUS’,
‘input’: {‘bounds’: {‘geometry’: {‘type’: ‘Polygon’,
‘coordinates’: geo15.825815, 46.714048],
l15.813988, 46.707248],
15.832682, 46.703062],
,15.839931, 46.711694],
,15.835353, 46.716664],
,15.825815, 46.714048]]]},
‘properties’: {}},
‘data’: >{‘dataFilter’: {‘timeRange’: {‘from’: ‘2017-01-01T00:00:00Z’,
‘to’: ‘2017-08-01T00:00:00Z’},
‘maxCloudCoverage’: 100.0,
‘maxSnowCoverage’: 100.0,
‘maxIncidenceAngle’: 90.0},
‘constellation’: ‘SPOT’,
‘products’: x{‘id’: ‘0f93ee6b-ea44-4a99-b4b4-c3c8d6ca8f2c’,
‘crsCode’: ‘urn:ogc:def:crs:EPSG::32633’},
{‘id’: ‘b412ce93-4426-418e-8666-f6a248631ea3’,
‘crsCode’: ‘urn:ogc:def:crs:EPSG::32633’},
{‘id’: ‘9a4743f3-ab07-4b9b-9b0e-60c3735d282a’,
‘crsCode’: ‘urn:ogc:def:crs:EPSG::32633’}]}],
‘provider’: ‘AIRBUS’},
‘sqkm’: 4.77,
‘status’: ‘CREATED’}

I tried order-‘id’] or order‘input’]‘data’]e0]‘products’]c0]e‘id’] and I have the error:

Server response: “{“error”:{“status”:404,“reason”:“Not Found”,“message”:“Collection 0f93ee6b-ea44-4a99-b4b4-***** not found.”,“code”:“COMMON_NOT_FOUND”}}”


My bad! With this method the BYOC collection ID isn’t stated. But when you confirm the order, it does create a BYOC collection that you can see in the dashboard under the name airbus query.


I checked your code: it looks good to go. Let me know if you get an error when confirming the order.


Hi,

Thank you for your help. Hence, I have copy/paste the ID from my Dashboard and I still cannot have access to the image

Server response: “{“error”:{“status”:404,“reason”:“Not Found”,“message”:“Collection 48eb11b7-c3c4-43fa-MASKED not found.”,“code”:“COMMON_NOT_FOUND”}}”


The ID you have provided is from “Configuration”, not “Collection”.

You will find your collections here:

favicon.icoapps.sentinel-hub.com

Dashboard







e.g. 3ee493ce-4f17-44bd-MASKED


Reply