Mask clouds on Landsat 8 surface reflectance

Get rid of clouds, shadows and snow in surface reflectance maps.

Use the code below or open this link.

// import the image
var img = ee.Image("LANDSAT/LC8_SR/LC81270472016041");

// set viz parameters
var viz = {bands:['B4','B3','B2'],min:0,max:3000};

//details for cfmask
//0=clear
//1=water
//2=shadow
//3=snow
//4=cloud

// we want no shadow, snow or cloud
var imgMask = img.mask(img.select('cfmask').lt(2));

// add to map
Map.addLayer(imgMask,viz,"without clouds");
Map.addLayer(img,viz,"with clouds");

One comment

Leave a Reply