1

I'm trying to get the Snow Cover extent from Sentinel-2 imagery using GEE. Here is my script: https://code.earthengine.google.com/1fbe39044e73c262fe935db00dc2adb3

The script performs the following:

  1. Create a Cloud Mask (expression based on S2 bands)
  2. Calculate the NDSI (expression based on S2 bands)
  3. Add Sentinel-2 imagery and sort them chronologically.
  4. Use mosaic.() to create a mosaic with the most recent images
  5. Create a Snow Cover Extent layer (expression based on the above created bands)

The problem is when I visualize the results I get strange values for pixels in the image overlap areas. The visualized values are different from the band values (used Inspector to check). For example, the white (cloud) strip at the right side of the image (see script) have a value of 1 (cloud) which is correct but the visualization is wrong (should be in red).

enter image description here

Even stranger, when I zoom in and out the visualization colors change!!

This makes me doubt what the mosaic () method really does. I thought only the most recent image is used.

can someone please look at the code and help me figure out what is going on ?

Thanks

1

The image shown in the Map is not the image at its native resolution. What is shown is controlled by the pyramiding policy of Google Earth Engine to allow rapid visualization.

In your case, the inspector is inconsistent with the visualized map because the masking is performed after mosaic is computed. This results in different masks being applied to the mosaic (according to the pyramiding policy).

.Mosaic allows you to overcome this problem by explicitly masking before computing the mosaic. From the documentation of Mosaicking:

To control the source of pixels in a mosaic (or a composite), use image masks.

Putting all of this together, rearrange your operations in the following order:

  1. Create a Cloud Mask (expression based on S2 bands)
  2. Calculate the NDSI (expression based on S2 bands)
  3. Add Sentinel-2 imagery and sort them chronologically.
  4. Create a Snow Cover Extent layer (expression based on the above created bands)
  5. Mask image using Snow Cover Extent layer
  6. Use .Mosaic() to create a mosaic with the most recent images

If you follow the above operations, the visualized layer seems to be as expected, and does not change with different zoom levels.

enter image description here Link to corrected script is here.

| improve this answer | |
  • @kkraro Thank you for looking into this. The code you provided seems to mask the background imagery as well. I tried adding a band that has only the masked Snow Cover layer but I'm running into the same problem even when masking before mosaiking. Any ideas ? here is the code: code.earthengine.google.com/545e37df12c633811e13c3b439d4e76c – moez.labiadh Jun 17 at 21:58
  • 1
    Sorry din't realize that you wanted only the snow cover masked. If you don't want to mask the background, then don't apply the mask on the background imagery. I have updated the image and script in the answer to reflect the same. – kkrao Jun 18 at 6:35
  • There still a problem. When masking no snow values. the layer will show values from the next available image. see below the code you suggested aplied to an other ROI : code.earthengine.google.com/df461e4c33b2c781f92daa5536b8b3dc – moez.labiadh Jun 18 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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