image collections 4

working with sentinel 2

calculate yearly water mask for the whole country.

step 1: add a geometry to the map

step 2: copy the code below and fill out the ??

var s2 = ee.ImageCollection("COPERNICUS/S2");

// filter for location
s2 = s2.filterBounds(??);

// print number of images

// filter for date;
s2 = s2.filterDate("??","??");

function removeClouds(image){
// get QA band
var QA ="??");
// get QA band
var clouds = QA.bitwiseAnd(Math.pow(2, 10)).eq(0);
var cirrus = QA.bitwiseAnd(Math.pow(2, 11)).eq(0);

// mask clouds and cirrus
return image.updateMask(clouds).updateMask(cirrus);


function calculateNDWI(image){
return image.normalizedDifference(['??','??']);

s2 =;
var ndwi =;


Leave a Reply

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

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

Facebook photo

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

Connecting to %s