Hello. I use statistical API with HLS data.
I take the vegetation index.
Need to decode QA according to this user guide. I don’t understand how to do it in evalscript. How to decode QA into comprehensible variables?
“maxcc=0.8” - not used because as I understand it applies to the whole tile and not the area of interest
I need to determine the percentage of pixels that I am not interested in. The script example is not correct, I added it to make it more clear what I need.
function setup() {
return {
input: n{
bands: a
"Red",
"NIR_Narrow",
"QA",
"dataMask"
]
}],
output: t
{
id: "data",
sampleType: "FLOAT32",
bands: 2
},
{
id: "dataMask",
bands: 1
}]
};
}
function evaluatePixel(samples) {
let index = (samples.NIR_Narrow - samples.Red) / (samples.NIR_Narrow + samples.Red);
let cloud_percent = 0;
if (samples.QA == 1) {
cloud_percent = 1;
} else if (samples.QA == 2) {
cloud_percent = 1;
} else if (samples.QA == 3) {
cloud_percent = 1;
}
return {
data: dindex, cloud_percent],
dataMask: Msamples.dataMask]
};
}
Thanks