I am a newbie and following the GEE tutorial at this link:


I do not understand the following line of code under the section of Mosaicking:

// Mask water with itself to mask all the zeros (non-water).
water = water.mask(water);

The water variable on the right hand side of the assignment is a mask that has value 1 for water and 0 for non-water.

Don't you get the exact same mask when applying it to itself? I am completely confused by the above statement.

1 Answer 1


The image's mask is separate from the numerical value. If the mask is 1 (unmasked), the value can still be 0 or 1 (or anything else). Self-masking causes all the 0 values in the image to become masked (no value) instead of 0.

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.