How can I replace masked pixels with another image?
I have two sets of images: Image_A and Image_B, each has 10 bands.
I want to change the masked pixels in Image_A by the corresponding (same band, line, and column) values from Image_B.
Image_A_Update = Image_A.updateMask(Image_A.unmask(Image_B))
If Image_B also has a mask for some pixels, the output would be the mask for those pixels.
Best Answer
This will be unmasked wherever at least one of the images is unmasked, using pixels from
Image_A
if available and pixels fromImage_B
otherwise.(This is the same operation as
ImageCollection.mosaic()
, just applied to two images instead of an entire collection.)