Search code examples
maskinggoogle-earth-engine

Simple Masking Burn Data with NDSI


I don't understand this error. I tried to Mask an image with another Image(containing only 0 and 1). It doesn't recognize the Mask as input image2.

Link to GEE Code

This Line Created following Error:

var MaskedBAI = First.updateMask(threshold);

Error: Required argument (image2) missing to function: Image.first(image1, image2)

Selects the value of the first value for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.

Args:

image1 (Image): The image from which the left operand bands are taken. image2 (Image): The image from which the right operand bands are taken.

mile Gracie


Solution

  • The masking in your code works just fine, your issue is with the use of .first().

    If used on an ImageCollection as you do in the beginning of your script, the first image of the collection is returned.

    If used on an Image it

    Selects the value of the first value for each matched pair of bands in image1 and image2

    as the description says. Which I guess not what you want. So the solution is easy, just get rid of the .first():

    Map.addLayer(MaskedBAI,BAIparam ,'BAI')
    

    Just to mention, no pixel is below your threshold of 0.3, which means the entire mask is 0, which in turn will show you nothing for MaskedBAI ... just in case you're wondering.