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( qa.bitwiseAnd(cirrusBitMask).eq(0)); // 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 Map.addLayer(water,{min:-1,max:0.5,palette:["red,yellow,blue"]},"water");