Cloud and water color - NDVI

Hi, I’m creating a custom NDVI image for an irrigation system I’m working on.
I’m already able to do all the work, pulling the images exactly where I want, integrating this into Google Maps, but now I have a problem.

In the image, you can see that clouds and water are in red, I would like to leave the clouds in white and the water in some other color that does not blend in with the field.
Here’s also the code I’m using.

let ndvi = (B08 - B04) / (B08 + B04);

 return colorBlend(ndvi,
    [-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,dataMask],							   //  < -.2 = #000000 (black)
     [165/255,0,38/255,dataMask],        //  -> 0 = #a50026
     [215/255,48/255,39/255,dataMask],   //  -> .1 = #d73027
     [244/255,109/255,67/255,dataMask],  //  -> .2 = #f46d43
     [253/255,174/255,97/255,dataMask],  //  -> .3 = #fdae61
     [254/255,224/255,139/255,dataMask], //  -> .4 = #fee08b
     [255/255,255/255,191/255,dataMask], //  -> .5 = #ffffbf
     [217/255,239/255,139/255,dataMask], //  -> .6 = #d9ef8b
     [166/255,217/255,106/255,dataMask], //  -> .7 = #a6d96a
     [102/255,189/255,99/255,dataMask],  //  -> .8 = #66bd63
     [26/255,152/255,80/255,dataMask],   //  -> .9 = #1a9850
     [0,104/255,55/255,dataMask]         //  -> 1.0 = #006837
    ]);

Hi Alan,

Sure, you should be able to classify cloud and water separately. However, I need some more information from you. Which sensor are you using? I’m guessing Sentinel-2 but I am not sure?

Yes, I’m using sentinel-2, TRUE-COLOR to perform this customization.
But can you help me with how I can make this difference for clouds and water?

Here is the dashboard configuration.

Hi Alan,

There are some scripts on the custom scripts repository that should be able to help you create your own custom visualisation:

I’m trying to adapt part of the cloud detection within my script, but when I call it within my app, I receive an error, but it doesn’t tell me what the error is, which is making my work difficult.
Is there any place where I can test the script and see what errors exist in it?

//VERSION=3
let ndvi = (B08 - B04) / (B08 + B04);

const classes = {
  0: [0, 0, 0], // No Data (Missing data) - black  
  1: [255, 0, 0], // Saturated or defective pixel - red 
  2: [47, 47, 47], // Topographic casted shadows ("Dark features/Shadows" for data before 2022-01-25) - very dark grey
  3: [100, 50, 0], // Cloud shadows - dark brown
  4: [0, 160, 0], // Vegetation - green
  5: [255, 230, 90], // Not-vegetated - dark yellow
  6: [0, 0, 255], // Water (dark and bright) - blue
  7: [128, 128, 128], // Unclassified - dark grey
  8: [192, 192, 192], // Cloud medium probability - grey
  9: [255, 255, 255], // Cloud high probability - white
  10: [100, 200, 255], // Thin cirrus - very bright blue
  11: [255, 150, 255], // Snow or ice - very bright pink
}

let imgVals = classes[SCL] || [0, 0, 0];

if(SCL == 6){
   return imgVals.concat(dataMask * 255);
  }
//
  

let test = colorBlend(ndvi,
    [-0.2, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0 ],
    [[0, 0, 0,dataMask],	             //  < -.2 = #000000 (black)
     [255/255,255/255,255/255,dataMask],      //  -> 0 = #a50026
     [215/255,48/255,39/255,dataMask],   //  -> .1 = #d73027
     [244/255,109/255,67/255,dataMask],  //  -> .2 = #f46d43
     [253/255,174/255,97/255,dataMask],  //  -> .3 = #fdae61
     [254/255,224/255,139/255,dataMask], //  -> .4 = #fee08b
     [255/255,255/255,191/255,dataMask], //  -> .5 = #ffffbf
     [217/255,239/255,139/255,dataMask], //  -> .6 = #d9ef8b
    [166/255,217/255,106/255,dataMask], //  -> .7 = #a6d96a
    [102/255,189/255,99/255,dataMask],  //  -> .8 = #66bd63
     [26/255,152/255,80/255,dataMask],   //  -> .9 = #1a9850
     [0,104/255,55/255,dataMask],        //  -> 0.95 = #006837
     [59/255,120/255,29/255,dataMask],
     [52/255,112/255,27/255,dataMask],
     [27/255,75/255,18/255,dataMask],
 [23/255,64/255,17/255,dataMask],        //  -> 0.95 = #006837
     [23/255,45/255,22/255,dataMask]         //  -> 1 = #006837
    ]);

return test;