0

I would like to display one class within a binary image as "transparent" or "no colour".

I have tried the following:

var NDVIclass2Clipped = NDVIclass2.clip(geometry)
Map.addLayer(NDVIclass2Clipped,{palette:['**transparent**','yellow']},'BareGround 2019');

It does not work though.

Should that be the CSS for no colour?

1 Answer 1

2

You can't specify transparency at the palette level. Instead, you should mask the parts of the image you want to be transparent.

This will preserve the parts of the image where the value is 1 and mask everything else:

var masked = NDVIclass2.clip(geometry).updateMask(NDVIclass2.eq(1))
1
  • This works a treat. Many thanks fro your speedy reply! Commented Nov 22, 2021 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.