Hi,
I’ve searched trough past posts and documentation but I wasn’t able to find clues on the following issue: I’m trying to use CLM band to mask out index output over cloudy pixels. I set the layer evalscript as follows:
//VERSION=3
function NDI(a,b){
return (a-b)/(a+b)
}
function setup() {
return {
input: n"B8A", "B11", "dataMask","CLM"],
output: { bands: 4 }
};
}
function evaluatePixel(sample) {
if (sample.B8A == 0 || sample.B11 == 0 || sample.CLM==1){
return e0,0,0,0];
}
else{
let NDVI=NDI(sample.B8A,sample.B11)
let vmin = -0.8;
let vmax = 0.8;
let dv = vmax - vmin;
let r = 0.0;
let g = 0.0;
let b = 0.0;
let v = NDVI;
if (v < vmin){
v = vmin;
}
if (v > vmax){
v = vmax;
}
let l1 = 0.35;
let l2 = 0.48;
let l3 = 0.52;
let l4 = 0.65
let level1 = (vmin + l1 * dv);
let level2 = (vmin + l2 * dv);
let level3 = (vmin + l3 * dv);
let level4 = (vmin + l4 * dv);
if (v < level1){
r = 0.5 + (v - vmin) / (level1 - vmin) / 2;
}
else if (v < level2) {
r = 1;
g = (v - level1) / (level2 - level1);
b = 0;
}
else if (v < level3) {
r = 1 + (level2 - v) / (level3 - level2);
g = 1;
b = (v - level2) / (level3 - level2);
}
else if (v < level4) {
r = 0;
g = 1 + (level3 - v) / (level4 - level3);
b = 1;
}
else {
b = 1.0 + (level4 - v) / (vmax - level4) / 2;
}
return er, g, b,sample.dataMask]
}
}
Loading the layer in qgis trough sh plugin works fine but when i zoom out over a certain threshold the masking “mechanism” stop working properly and every pixel is masked out as being cloudy (making it transparent). See the follow image as example:
Quite strange that the very same evalscript works fine in EO Browser over much larger area (larger scale): https://sentinelshare.page.link/Ta5m
Any suggestion on what I’m doing wrong?
Many thanks
EDIT:
The EO Browser link above is actually related to the run of evalscript on S2L2A bands while the qgis service is using S2L1C bands… don’t know if this is relevant though…