This would require multi-temporal processing, which is currently supported only on our “main” service (e.g. services.sentinel-hub.com). On EO Cloud (eocloud.sentinel-hub.com) this is coming soon.
To do a multi-temporal request, you need to add parameter TEMPORAL=true and configure your layer appropriately, e.g. to calculate mean values.
I do not have anything sentinel-1 specific handy, but you can find two related cases with Sentinel-2:
https://github.com/sentinel-hub/custom-scripts/blob/master/sentinel-2/max_ndvi/script.js
(maximum value over a period of time)
(https://github.com/sentinel-hub/custom-scripts/blob/master/sentinel-2/cloudless_mosaic/L2A-first_quartille.js)
first quartile value.
Are there any updates regard this topic? e.g get median/mean values of bands/spectral indices within specific time period? for example,month?
Hi Reut,
Getting median or mean values for a specific time period can either be done with the Statistical API if you need a value for a given area or can be coded in an Evalscript if you need a raster back. Do you have a specific use-case in mind?
Hi Maxim!
yes, the idea is to calculate mean or median values for lets say one ear per month.
This should be per pixel, so the result should be a raster.
I wonder if there is nice way to do that in one request without for loop that sends many requests.
If you set the parameter mosaicking: "ORBIT"
in the setup
function in your Evalscript, you will be able to access the dates of the images available within the time-range set in the payload, e.g.
function evaluatePixel(samples, scenes) {
firstDate = scenes[0].date
lastDate = scenes[scenes.length-1].date
}
From there, you can classify the data in the Evalscript according to dates and compute averages.
Below is an example to get you started that you can build on. For this example I set a time-range from 01/07/2022 to 31/08/2022:
//VERSION=3
function setup() {
return {
input: ["B02"],
output: { bands: 1 },
mosaicking: "ORBIT"
};
}
function average(array){
// Compute average of an array
var sum = 0;
for( var i = 0; i < array.length; i++ ){
sum += array[i]
}
return sum/array.length
}
function evaluatePixel(samples, scenes) {
// Make an object that will contain values and number of samples
monthlyValues = {}
for (let i = 0; i < scenes.length; i++){
let year = scenes[i].date.getFullYear()
let month = scenes[i].date.getMonth()
// Add year key to the Object if not already existing
if (!(year in monthlyValues)){
monthlyValues[year] = {}
}
// Add month key to the Object if not already existing and
// prepare an empty array for values
if (!(month in monthlyValues[year])){
monthlyValues[year][month] = {"values": []}
}
// Add samples to the object
monthlyValues[year][month].values.push(samples[i].B02)
}
// Example for a month average
var month1Average = average(monthlyValues["2022"]["6"].values)
return [month1Average]
}