Skip to main content

I am not much of a Python programmer and haven’t used this GET API before, so I keep running into basic questions. At the moment, I’m curious what “samples” refers to in “function evaluatePixel(samples)”? The source of the script is here.

 

function evaluatePixel(samples) {
var S2L1C = samples.S2L1Cs0];
var S1 = samples.S1GRDs0];
let WAT = 25; // Water Threshold for SAR
let CLP = S2L1C.CLP / 2.55; // Cloud Propability
let CLPT = 70; // Cloud Propabilty Threshold in percent

if ((CLP > CLPT && S1.VV / S1.VH <= WAT)) {
return {
default: S1.VV * 3.0, S1.VV * 1.1 + S1.VH * 8.75, S1.VH * 1.75]
}
}

if ((CLP > CLPT && S1.VV / S1.VH > WAT)) {
return {
default: S1.VV * 1, S1.VV * 8, 0.5 + S1.VV * 3 + S1.VH * 2000]
}
}


let val = >3 * S2L1C.B04, 3 * S2L1C.B03, 3 * S2L1C.B02];
return {
default: val
}
}

 

As I’m trying to develop my script, if I have an AOI, would I replace “samples” with whatever I’ve named my AOI? Or with the Sentinel-2 scene?

Hi! Cheers for the question! The script you refer to should work straight out of the box like in this example in EO Browser. You should not be adjusting the samples as this refers to the satellite scenes being used in the evalscript. Your AOI and time range are actually defined outside of this in your request payload.

For more info on what exactly samples refers to, I encourage you to read through this documentation page: https://docs.sentinel-hub.com/api/latest/evalscript/v3/#samples

In addition, here is a full example of a request using the evalscript you were referring to: https://docs.sentinel-hub.com/api/latest/data/data-fusion/examples/#replace-clouds-in-sentinel-2-images-with-sentinel-1-data

If you copy and paste this into Request Builder as a curl request, you can than translate this into python code.


Reply