sentinel-hub/sentinelhub-py

[HELP] Download classification label maps

cpbridges opened this issue · 2 comments

Checked the forum already - sorry! Is it possible to download the classification label maps?
I've been looking at https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2/scene-classification/

My login is fine - works on other code but the output is:

DownloadFailedException: Failed to download from:
https://services.sentinel-hub.com/api/v1/process
with HTTPError:
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: "{"error":{"status":400,"reason":"Bad Request","message":"Output dataMask requested but missing from function setup()","code":"COMMON_BAD_PAYLOAD"}}"

My code is:

process_requests = []
for timestamp in unique_acquisitions:
    request = SentinelHubRequest(
        evalscript=datamask_evalscript,
        input_data=[
            SentinelHubRequest.input_data(
                data_collection=DataCollection.SENTINEL2_L2A,
                time_interval=(timestamp - time_difference, timestamp + time_difference),
            )
        ],
        responses=[
            SentinelHubRequest.output_response("dataMask", MimeType.PNG) # CB: Doesn't work
        ],
        bbox=caspian_sea_bbox,
        size=bbox_to_dimensions(caspian_sea_bbox, 100),
        config=config,
    )
    process_requests.append(request)

And:

client = SentinelHubDownloadClient(config=config)
download_requests = [request.download_list[0] for request in process_requests]
data = client.download(download_requests)
data[0].shape

Hi @cpbridges,

In the evalscript that you are using you can see in setup function the part with:

output: { bands: 4 }

This means that the evalscript will be returning a single image response with a default name. Because of that you have to set in your Python code in SentinelHubRequest parameter:

responses=[
    SentinelHubRequest.output_response("default", MimeType.PNG)
],

Then I believe it should work.

Thank you AlexMat - I knew it was something silly. Works now!