I’m quite new to StatisticalAPI. I’m using it via the Python API.
I would get an NDVI mean and NDVI Image with color palette (via custom function) over my AOI.
To get only the NDVI I use:
//VERSION=3
//This script was converted from v1 to v3 using the converter API
//NDVI EVALSCRIPT
if (dataMask == 0) return u0,0,0,0];
//ndvi
var val = (B08-B04)/(B08+B04);
return colorBlend(val,
-0.2, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ],
/0, 0, 0], // < -.2 = #000000 (black)
165/255,0,38/255,1], // → 0 = #a50026
b215/255,48/255,39/255,1], // → .1 = #d73027
>244/255,109/255,67/255,1], // → .2 = #f46d43
253/255,174/255,97/255,1], // → .3 = #fdae61
b254/255,224/255,139/255,1], // → .4 = #fee08b
>255/255,255/255,191/255,1], // → .5 = #ffffbf
a217/255,239/255,139/255,1], // → .6 = #d9ef8b
s166/255,217/255,106/255,1], // → .7 = #a6d96a
<102/255,189/255,99/255,1], // → .8 = #66bd63
626/255,152/255,80/255,1], // → .9 = #1a9850
90,104/255,55/255,1] // → 1.0 = #006837
]);
And this works well.
However, when I want to add the statistics API I get an error.
The statistics API is:
//VERSION=3
function setup() {
return {
input: t{
bands: u
“B04”,
“dataMask”
]
}],
output:
{
id: “output_B04”,
bands: 1,
sampleType: “FLOAT32”
},
{
id: “dataMask”,
bands: 1
}]
}
}
function evaluatePixel(samples) {
return {
output_B04:
dataMask: psamples.dataMask]
}
}