Hello, thank you for your help.
I’m currently working with the script below that sent me Mr. Milcinski , but I can’t get the visualization I need. The script shows some changes in NDVI, but I’m only interested in tree values and only those that are decreasing. Practically I am trying to script showing this anomaly. But currently the script visualizes all surfaces in red and it’s hard to find the anomaly I need. Since healthy trees have an ndvi value higher than 0.8, I would like the script to show only the places with decline rate from this value.
Script:
//VERSION=3
//This script was converted from v1 to v3 using the converter API
function setup() {
return {
input: [{
bands: [
"B04",
"B08"
]
}],
output: {
bands: 3
},
mosaicking: "ORBIT"
}
}
function calcNDVI(sample) {
var denom = sample.B04+sample.B08;
return ((denom!=0) ? (sample.B08-sample.B04) / denom : 0.0);
}
function evaluatePixel(samples) {
var ndvi_last = calcNDVI(samples[0]);
var ndvi_first = calcNDVI(samples[samples.length - 1]);
var diff = ndvi_last - ndvi_first;
return valueInterpolate(diff, [-1, 0, 1], [
[1, 0, 0],
[1, 1, 1],
[0, 1, 0]
]);
}
function filterScenes (scenes, inputMetadata) {
return scenes.filter(function (scene) {
return scene.date.getTime()>=(inputMetadata.to.getTime()-2*31*24*3600*1000) ;
});
}