Skip to main content

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?


Thank you in advance! 😁

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:


https://www.sentinel-hub.com/develop/documentation/api/fis-request


FIS performs statistical analysis over some area and returns the results. Is this what you are looking for?


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:

favicon.svggithub.com

custom-scripts/sentinel-2/max_ndvi at master · sentinel-hub/custom-scripts



master/sentinel-2/max_ndvi



A repository of custom scripts to be used with Sentinel Hub







Well, I need for statistical analysis, I’ll see that link you sent, I can not say It if It is what I need in my case.


I took a look in the example script but I did not find that part of code where calculates the standard deviation could you explain to me please?


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(samplespi]);
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:
favicon.icoDustin John Pfister at github pages

Finding Standard Deviation in javaScript



In Statistics it seems like standard deviation is something that comes up often. So why not just go ahead and cover this one when it comes to launching my new series of posts on working with statistic







If not, I am sure you can find other examples on how to calculate standard deviation from an array or values.


Thank you! I’ll try to implement what I need and tell you as soon as possible if I got success 😃


Reply