Style and values for the barren soil layer

i’m using the great script written by @monja.sebela and there is something I would like to understand better.
When I create the layer in the configuration utility, it looks like there is no definition for the style however, when I open it oin th eplayground it has colors and seems like it has so rule which pixels get “pink” values or green values.
How does it determined ?

On the same topic, when I generate for example GNDVI layer using this script:

function setup() {
  return {
    input: ["B09", "B03", "CLM"],
    output: {
      bands: 1, 
      sampleType: "FLOAT32"

function evaluatePixel(sample) {
    if (sample.CLM == 1) {
        return [null]
    const gndvi = index(sample.B09, sample.B03);
    return [gndvi];

and then I open in the playground, it has no symbology and cant be displayed.
So my questoin here- why in the barren soil it gets color and in GNDVI layer it doesnt? and what is the rule for the barren soil colors? which values?



Dear Reut, I’m not sure I understand what the problem with the barren soil script is. The script is explained here, where it states that vegetation is colored green due to B08 being in the green channel, and barren ground is red, due to BSI being in the red channel. Everything reflected by B11 will appear blue. The higher the BSI, the redder the area, and the denser the vegetation, the greener it will be. It’s essentially an RGB composite with an index in the red channel, and bands in the other two. A useful trick might be to return components of the script (for example B08, or the BSI) you don’t understand in grayscale, so you see exactly what they return. Our custom script resources should also help you understand how to read custom scripts and make sense of them.

I’m not sure why it wouldn’t work if you add it as a layer in your configuration utility. If you send me a private message with the configuration ID (do not post the ID in the public forum!) and the name of the layer in question, I can check for any errors.

For the GNDVI, the script returns FLOAT32 bit values, and float values are not supported by PNG/JPEG. As EO Browser and Playground display images, you get an error. FLOAT32 is intended for TIFF analysis.
Remove this part (AUTO will be used) or change it to UINT8, and your script should display a grayscale image. Link

Hey Monja!

thank you for your answer.
maybe I wasn’t clear enough, I just didn’t understood how the color determined in the script in the end.
I think my confusion is because many times I return more than 3 bands, and I didn’t know that if I return 3 bands than they are considered as RGB (?).

So if I understand your answer correct, it return RGB, and in the barren soil, you used BSI but didn’t return only the BSI, but also return B08 and B02, and then it got colors based on reflectence in these bands?

and regard the GNDVI - it worked. thanks.

Yes, your understanding is correct. 3 bands in the output always mean RGB in our custom scripts. The 4. band is reserved for transparency (and when returning single band grayscale, second band is for transparency). Please check the beginner scripting tutorial and the custom scripts webinars for information about RGB, transparency, etc. These resources hold a lot of information and we made them as we believe our users would benefit greatly from having a strong understanding of custom scripts.

1 Like