for sentinel-3-OLCI, i am using the below posted evalscript to have statistical information using statistical-api.
please let me know why the app crashes when attempts to process the evalscript?
evalscript:
const evalscript =
`
//VERSION=3
function setup() {
return {
input: [{
bands: ["B08", "B17", "dataMask"],
units: "DN"
}],
output: [
{
id: "ndvi",
bands: 1,
},
{
id: "dataMask",
bands: 1,
}
]
}
}
function evaluatePixel(samples) {
// Precompute an array to contain NDVI observations
if (!samples) {
return {
ndvi: [NaN],
dataMask: [NaN]
};
}
if (samples.length < 1) {
return {
ndvi: [NaN],
dataMask: [NaN]
};
}
let index = null;
if (samples.B17 + samples.B08 === 0) {
index = 0; // to avoid division by zero
return {
ndvi: [index],
dataMask: [samples.dataMask]
};
}
index = (samples.B17 - samples.B08) / (samples.B17 + samples.B08);
return {
ndvi: [index],
dataMask: [samples.dataMask],
};
}`