[GIS] Creating opacity mask in Google Earth Engine

google-earth-enginelandsatmaskingopacity

I have an NDSI snow layer loaded in Google Earth Engine. Since snow is present for values <0.4, I want to make values >0.4 opaque. I looked at the manual's examples, but this code is not giving me what I want. Instead I get black (<0.40) and white (>0.40).

What am I missing?

var winter = NDSI.filter(ee.Filter.calendarRange(1999,2018,'year')).filter(ee.Filter.calendarRange(6,8,'month'));
var medianWinter = winter.median();
var medianWinterMask = medianWinter.gt(0.4);
Map.addLayer(medianWinterMask);

Best Answer

To mask an image, use the method ee.Image.updateMask(). Masking is also covered in the Introduction to the Earth Engine JavaScript API tutorial.

There are many ways to present masked data, but here is one possibility using the variables from your example code:

Map.addLayer(medianWinter.updateMask(medianWinterMask), {min:0, max:100});
Related Question