I am needing to apply a kind of “validations” in the request script, I didn’t get anywhere though.
e.g: I need to get the standard deviation of a band using a function and its return should be less than 130, if it’s true, another comparison get done.
The problem is: I couldn’t find any way to access the pixels of the band to calculate the standard deviation, the pixels should be an array.
Someone have any idea how can I get the all pixels to apply my function?
I have a bit of a hard time understanding the challenges you have.
Can you copy-paste here your full script, so that we can try it out, then state, what exactly you would like to add to this script.
I could not develop a script yet, I’ll write an script example of my idea:
const standard_deviation = (band) => // here goes the formula using band pixels
if (standard_deviation(B02) < 200) {
if (standard_deviation(B08) < 100) {
// ... more validations
}
}
Is that possible to access band pixels on script request?
I am not completely sure I understand exactly what you are trying to achieve, but if you would like to observe distribution of values for some band, there is a service which might suit your needs:
Another option is to use multi-temporal processing, where you browse through all the values of the pixel and you simply calculate standard deviation.
See an example of a multi-temporal script:
This part loops through all the values at the specific location (pixel). In the given example a simple “max” is calculated. You can evolve this to create standard deviation
function evaluatePixel(samples) {
var max = 0;
for (var i=0;i<samples.length;i++) {
var ndvi = calcNDVI(samples[i]);
max = ndvi > max ? ndvi:max;
}
Not all JavaScript functions are supported, but perhaps worth to check if the example provided here would work in your case:
If not, I am sure you can find other examples on how to calculate standard deviation from an array or values.