Third party data download issues

Hello all,

I am a very newbie using the Sentinelhub API. I currently have requested imagery of Pleiades, and I am trying to download it through the Sentinel Hub Python package by using the following code:

So my question is, how can I download it to my disk in a tiff format?

(I have already imported the libraries and set my credentials),*

response = oauth.post('https://services.sentinel-hub.com/api/v1/process',*
headers={"Authorization" : "Bearer {}".format(token)},
json={
    'input': {
        "bounds": {
            "properties": {
                "crs": "http://www.opengis.net/def/crs/EPSG/0/{}".format(4326)
            },
            "bbox": [-46.74869460121712, -0.9729251789917431, -46.64665760474313, -0.889532997887468]
        },
        "data": [{
            "type": "CUSTOM",
            "dataFilter": {
                "collectionId": collectionid,
                "timeRange": {
                    "from": "2017-06-16T00:00:00Z",
                    "to": "2017-12-17T00:00:00Z"
                }
            }
        }]
    },
    "output": {
        'resx': 0.0000938,
        'resy': 0.0000938,
        "responses": [
            {
                "identifier": "default",
                "format": {
                    "type": "image/tiff"
                }
            }
        ]
    },
    "evalscript": """
        //VERSION=3
        function setup() {
            return {
                input: [{"bands": ["B0", "B1", "B2", "B3"], units: "DN"}],
                output: { id: "default", bands: 4, sampleType: SampleType.UINT16}
            };
        }
        function evaluatePixel(sample) {
            return [sample.B0, sample.B1, sample.B2];
        }
    """
})

#Saving the response content in tif file
with open(‘test_out.tif’, ‘wb’) as f:
f.write(response.content)

Hi Sergio,

I assumed you wanted to download all 5 Pleaides bands in your output file and I adjusted your evalscript accordingly. Some other examples of evalscripts you can use for Pleiades data can be found here.

In the snippet below, you only need to input your collectionId (get it in your SH Dashboard) in the beginning and it should download the tif file for you:

import requests

collectionId = "" # input your collectionId

url = "https://services.sentinel-hub.com/api/v1/process"

headers = {
  "Content-type": "application/json",
  'Authorization': f'Bearer {token["access_token"]}'
}

json={
    'input': {
        "bounds": {
            "properties": {
                "crs": "http://www.opengis.net/def/crs/EPSG/0/{}".format(4326)
            },
            "bbox": [-46.74869460121712, -0.9729251789917431, -46.64665760474313, -0.889532997887468]
        },
       "data": [{
            "type": f"byoc-{collectionId}",
            "dataFilter": {
                "timeRange": {
                    "from": "2017-06-16T00:00:00Z",
                    "to": "2017-12-17T00:00:00Z"
                }
            }
        }]
    },
    "output": {
        'resx': 0.0000938,
        'resy': 0.0000938,
        "responses": [
            {
                "identifier": "default",
                "format": {
                    "type": "image/tiff"
                }
            }
        ]
    },
    "evalscript": """
        //VERSION=3
        function setup() {
            return {
                input: [{"bands": ["B0", "B1", "B2", "B3", "PAN"], units: "DN"}],
                output: { id: "default", bands: 5, sampleType: SampleType.UINT16}
            };
        }
        function evaluatePixel(sample) {
            return [sample.B0, sample.B1, sample.B2, sample.B3, sample.PAN];
        }
    """
}

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

with open('test_out.tif', 'wb') as f: 
     f.write(response.content)

Best, Anja