rizwanasif
(Muhammad Rizwan Asif)
1
I am trying to use the evalscript example given in Evalscript V3 to try to access multi-temporal data.
To get one image, as in the code below, it works fine
evalscript_true_color = """
//VERSION=3
function setup() {
return {
input: [{
bands: ["B02"]
}],
output: {
bands: 1
}
};
}
function evaluatePixel(sample) {
return [sample.B02];
}
"""
request_true_color = SentinelHubRequest(
evalscript=evalscript_true_color,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=("2022-01-01", "2023-12-31"),
mosaicking_order=MosaickingOrder.LEAST_CC,
)
],
responses=[SentinelHubRequest.output_response("default", MimeType.PNG)],
bbox=bbox,
size=size,
config=config,
)
true_color_imgs = request_true_color.get_data()
print(f"Returned data is of type = {type(true_color_imgs)} and length {len(true_color_imgs)}.")
rizwanasif
(Muhammad Rizwan Asif)
2
However, when I modify it based on the link as in the below code
evalscript = """
//VERSION=3
function setup() {
return {
input: [{
bands: ["B02"],
}
],
output: [{
id: "default",
bands: 1,
sampleType: "UINT16"
}
],
mosaicking: "TILE"
}
}
function updateOutput(output, collection) {
output.default.bands = collection.scenes.length;
}
function evaluatePixel(samples) {
var n_scenes = samples.length;
let band_b02 = new Array(n_scenes);
// Arrange values of band B02 in an array
for (var i = 0; i < n_scenes; i++){
band_b02[i] = samples[i].B02;
}
return {
default: band_b02
};
}
"""
time_interval = ('2023-01-01', '2023-01-10')
request = SentinelHubRequest(
evalscript=evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=time_interval,
)
],
responses=[
SentinelHubRequest.output_response('default', MimeType.PNG)
],
bbox=bbox,
size=size,
config=config
)
images = request.get_data()
print(f"Total number of images retrieved: {len(images)}")
It still returns one image. I hope somebody can help me figure out what I am doing wrong?
It should still return only one image, however that image should have as many bands as there are acquisitions in the time series.
Open up the image in QGIS and check the number of bands, it should all be there.
rizwanasif
(Muhammad Rizwan Asif)
4
ah yes! I did not check the shape of the returned ‘images’. It has everything in it, thank you
-