Examples of SkySat Data Import
The examples below include the examples of both Simple and Native search so that you can compare their interfaces even though both would usually not be used in the same workflow. Similar applies for the examples of Order products and of Order using query. To execute the requests you need to create an OAuth client as is explained here. It is named oauth
in these examples.
SkySat data import
Search
Simple Search
For SkySat simple search, provider
must be set to "PLANET".
url = "https://services.sentinel-hub.com/api/v1/dataimport/search"query = {"provider": "PLANET","bounds": {"geometry": {"type": "Polygon","coordinates": [[[14.424468, 46.022168],[14.425053, 46.022157],[14.425088, 46.021768],[14.424615, 46.021753],[14.424264, 46.021926],[14.424468, 46.022168],]],}},"data": [{"itemType": "SkySatCollect","productBundle": "analytic_udm2","dataFilter": {"timeRange": {"from": "2016-01-01T00:00:00.000Z","to": "2022-01-01T00:00:00.000Z",}},}],}response = oauth.post(url, json=query)response.raise_for_status()results = response.json()
To get product ids:
item_ids = [feature["id"] for feature in results["features"]]
Native Search
This native search is equivalent to the above simple search. Note the added Planet-specific filters PermissionFilter
and AssetFilter
.
url = "https://services.sentinel-hub.com/api/v1/dataimport/nativesearch"payload = {"provider": "PLANET","item_types": ["SkySatCollect"],"filter": {"type": "AndFilter","config": [{"type": "GeometryFilter","field_name": "geometry","config": {"type": "Polygon","coordinates": [[[14.424468, 46.022168],[14.425053, 46.022157],[14.425088, 46.021768],[14.424615, 46.021753],[14.424264, 46.021926],[14.424468, 46.022168],]],},},{"type": "DateRangeFilter","field_name": "acquired","config": {"gte": "2016-01-01T00:00:00.000Z","lte": "2022-01-01T00:00:00.000Z",},},{"type": "PermissionFilter", "config": ["assets:download"]},{"type": "AssetFilter", "config": ["ortho_analytic_udm2"]},],},}response = oauth.post(url, json=payload)response.raise_for_status()results = response.json()
To get product ids:
item_ids = [feature["id"] for feature in results["features"]]
Thumbnail
After searching for data, you can check the thumbnail of each item by entering the item id into the url of the thumbnail request:
item_id = '20210612_125104_ssc19_u0001'# or get it from search results: item_id = item_ids[5]url = f"https://services.sentinel-hub.com/api/v1/dataimport/collections/PLANET_SKYSAT/products/{item_id}/thumbnail"response = oauth.get(url)
The thumbnail can be displayed in Python using:
import iofrom PIL import Imageimage_bytes = io.BytesIO(response.content)Image.open(image_bytess)
Order
To order SkySat data, provider
must be set to "PLANET" and data.itemType
to "SkySatCollect".
Order products
To order the import of the products, which we got as a result of search and are stored in the variable item_ids
:
url = "https://services.sentinel-hub.com/api/v1/dataimport/orders"payload = {"name": "planet skysat products 2021",# collectionId is optional. Remove it to create a new collection."input": {"provider": "PLANET","planetApiKey": <your-planet-api-key>,"bounds": {"geometry": {"type": "Polygon","coordinates": [[[14.424468, 46.022168],[14.425053, 46.022157],[14.425088, 46.021768],[14.424615, 46.021753],[14.424264, 46.021926],[14.424468, 46.022168],]],}},"data": [{"itemType": "SkySatCollect","productBundle": "analytic_udm2","harmonizeTo": "NONE","itemIds": ["20210612_125104_ssc19_u0001"], # [item_ids[5]]}],},}response = oauth.post(url, json=payload)response.raise_for_status()results = response.json()results
To extract the order id from the response:
order_id = results['id']
To extract the cost in square kilometers:
sqkm = results['sqkm']
Order using query
Another way to order data is using search query, in this case using the query
from above:
url = "https://services.sentinel-hub.com/api/v1/dataimport/orders"query['planetApiKey'] = <your-planet-api-key>query['data'][0]["harmonizeTo"] = "NONE"payload = {"name": "skysat order using query",# collectionId is optional. If it is not provided a new collection will be created automatically."collectionId": "<your Planet SkySat collectionId>","input": query}response = oauth.post(url, json=payload)response.raise_for_status()order = response.json()order
To extract the order id from the response:
order_id = order['id']
To extract the cost in square kilometers:
sqkm = order['sqkm']
Order Panchromatic bands
To order a panchromatic band set productBundle
value to panchromatic
.
url = "https://services.sentinel-hub.com/api/v1/dataimport/orders"payload = {"name": "planet skysat products panchromatic band 2021",# collectionId is optional. Remove it to create a new collection."collectionId": "<your Planet SkySat collectionId>","input": {"provider": "PLANET","planetApiKey": "<your-planet-api-key>","bounds": {"geometry": {"type": "Polygon","coordinates": [[[14.424468, 46.022168],[14.425053, 46.022157],[14.425088, 46.021768],[14.424615, 46.021753],[14.424264, 46.021926],[14.424468, 46.022168],]],}},"data": [{"itemType": "SkySatCollect","productBundle": "panchromatic","harmonizeTo": "NONE","itemIds": ["20210612_125104_ssc19_u0001"], # [item_ids[5]]}],},}response = oauth.post(url, json=payload)response.raise_for_status()results = response.json()results
To extract the order id from the response:
order_id = results['id']
To extract the cost in square kilometers:
sqkm = results['sqkm']
Confirm the order
Confirming the order will subtract the ordered area in km2 from your quota. To initiate import, confirm the order:
url = f"https://services.sentinel-hub.com/api/v1/dataimport/orders/{order_id}/confirm"response = oauth.post(url)response.raise_for_status()
Get order information
url = f"https://services.sentinel-hub.com/api/v1/dataimport/orders/{order_id}"response = oauth.get(url)response.raise_for_status()order = response.json()
To extract the order status:
status = order['status']
To extract the BYOC collection ID:
collection_id = order['collectionId']
List all your orders
url = "https://services.sentinel-hub.com/api/v1/dataimport/orders"response = oauth.get(url)response.raise_for_status()response.json()
Access SkySat data in a BYOC collection and process a truecolor image
This is a normal Processing API request that uses a BYOC collectionId
that can be fetched from the get order information request. To access a panchromatic band, you will have to adjust the evalscript so that it uses band name "PAN".
from PIL import Imageevalscript = """//VERSION=3function setup() {return {input: [{"bands": ["Blue", "Red", "Green","dataMask"]}],output: { bands: 4}};}var f = 2.5 / 10000function evaluatePixel(sample) {return [sample.Red*f, sample.Green*f, sample.Blue*f, sample.dataMask];}"""payload = {"input": {"bounds": {"properties": {"crs": "http://www.opengis.net/def/crs/EPSG/0/32633"},"bbox": [455436.85, 5096625.41, 455500.63, 5096671.07],},"data": [{"type": "byoc-<collectionId>","dataFilter": {"timeRange": {"from": "2021-06-01T00:00:00Z","to": "2021-06-30T23:59:59Z",}},}],},"evalscript": evalscript,"output": {"resx": 0.5, "resy": 0.5},}headers = {"Content-type": "application/json"}response = oauth.request("POST",url="https://services.sentinel-hub.com/api/v1/process",headers=headers,json=payload,)stream_prod = io.BytesIO(response.content)img_prod = Image.open(stream_prod)img_prod