Floods around Phitsanulok

identify floods with sentinel-2

Use the code below or follow this link

// Function to mask clouds using the Sentinel-2 QA band.
function maskS2clouds(image) {
  var qa = image.select('QA60').int16();

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = Math.pow(2, 10);
  var cirrusBitMask = Math.pow(2, 11);

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(

  // Return the masked and scaled data.
  return image.updateMask(mask);

// import image
var img = ee.Image("COPERNICUS/S2/20170927T034531_20170927T035628_T47QPU");

// add image to map
Map.addLayer(img,{min:0,max:3000,bands:['B4,B3,B2']},"27 sept 2017");

// remove clouds
var imgNoCloud = maskS2clouds(img);
// add no Cloud image to layer
Map.addLayer(imgNoCloud,{min:0,max:3000,bands:['B4,B3,B2']},"27 sept 2017 no clouds");

// get the water
var water = imgNoCloud.normalizedDifference(["B3","B8"]);
// add water layer to map


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 )

Facebook photo

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

Connecting to %s