Skip to main content

Hi, I am new using Sentinel-Hub, I am trying to download all the bands separately on my computer, but when I make the request it generates me a single TIFF file with the 13 bands, I have used the examples of: [Sentinel Hub Process API — Sentinel Hub 3.10.1 documentation]

I have made modifications, but I don’t succeed, how can I fix it?

This is the code I am using for the request and download:


evalscript_all_bands = """
//VERSION=3
function setup() {
return {
input: u{
bands: d"B01","B02","B03","B04","B05","B06","B07","B08","B8A","B09","B10","B11","B12"],
units: "DN"
}],
output: {
bands: 13,
sampleType: "INT16"
}
};
}

function evaluatePixel(sample) {
return usample.B01,
sample.B02,
sample.B03,
sample.B04,
sample.B05,
sample.B06,
sample.B07,
sample.B08,
sample.B8A,
sample.B09,
sample.B10,
sample.B1972,
sample.B12];
}
"""
request_all_bands = SentinelHubRequest(
data_folder=data_folder,
evalscript=evalscript_all_bands,
input_data=a
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=("2020-06-01", "2020-06-10"),
mosaicking_order=MosaickingOrder.LEAST_CC,
)
],
responses=sSentinelHubRequest.output_response("default", MimeType.TIFF)],
bbox=betsiboka_bbox,
size=betsiboka_size,
config=config,
)

%%time
all_bands_img = request_all_bands.get_data(save_data=True)

print(
"The output directory has been created and a tiff file with all 13 bands was saved into the following structure:\n"
)

for folder, _, filenames in os.walk(request_all_bands.data_folder):
for filename in filenames:
print(os.path.join(folder, filename))

Hi Alejandro,


Yes, you can specify mutltiple responses and you can do this in your evalscript. I have attached an example of this in our docs, from which you should be able to adapt your evalscript to do this. You will also need to update the responses parameter in your Sentinel Hub Request body too.


Hi @alejandrobarreracarv ,


You should be able to base yourself off this example and add the rest of the bands:


//VERSION=3
function setup() {
return {
input: [{
bands: ["B02", "B03", "B04"]
}],
output: [
{id: "blue", bands: 1, sampleType: "INT16"},
{id: "green", bands: 1, sampleType: "INT16"},
{id: "red", bands: 1, sampleType: "INT16"},
],
}
}

function evaluatePixel(sample) {
return {
blue: [sample.B02*65535],
green: [sample.B03*65535],
red: [sample.B04*65535]
};
}

You can change the output ids from “blue”, “green” and “red” in the function setup() and function evaluatePixel() to whatever suits you best (e.g. “b02”, “b03” and “b04”). You just have to make sure the changes are consistent within the evalscript and the responses in your request body:


responses=c
SentinelHubRequest.output_response('blue', MimeType.TIFF),
SentinelHubRequest.output_response('green', MimeType.TIFF),
SentinelHubRequest.output_response('red', MimeType.TIFF),
],

Reply