I have classified an image having a class by the name lights. It has value equal to zero. I select the mask by using
var lights_mask = classified_image.eq(0).selfMask(); //binary mask
Now I want to subtract the original image from this raster mask.
I have used both methods
var masked_image = image.updateMask(lights_mask);
//or
//var masked_image = image.subtract(lights_mask);
But it returns the original image with masked portion only. I want the mask portion to be removed and the rest of the multi-band image remains the same.
Simple put I want to clip a raster using a raster binary mask
Best Answer
I think you want
.selfMask().mask()
.