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");

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s