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
print(s2.size());

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

function removeClouds(image){
// get QA band
var QA = image.select("??");
// 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 = s2.map(??);
var ndwi = s2.map(??).??;

Map.addLayer(ndwi,{min:-0.1,max:0.3,palette:"green,blue"},"ndwi");
Advertisements

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s