Flood mapping with sentinel 2 in the earth engine

Sentinel-2 data is awesome, Just like Landsat.. but better!

Sentinel-2 is an Earth observation mission developed by ESA to perform terrestrial observations in support of services such as forest monitoring, land cover changes detection, and natural disaster management. It consists of two identical satellites. The complete archive is available in the Google Earth Engine.

Step 1. Type Sentinel-2 in the search box and open the sentinel-2 screen as seen below.

s2

Questions 1: What is the minimal and maximal spatial resolution?

Question 2: What is the timeframe covered by the dataseries?

Question 3: Compare the bands with bands of landsat-8. What are the similarities and differences?

Step 2: Click the import button to import the data as a imageCollection and call it S2.

Step 3:  Copy the template into a new script and fill in the author details, date and contact information.

Step 4: Import the fusion table of the Ca basin or upload your own fusion table as seen here.

// import the sub basins as a fusion table
var Ca = ee.FeatureCollection('ft:11uQewh4u7NFXneH99YPs6P9F1Au6wxBq959BZWt_','geometry');

Step 5. Define the time range using the statement below

// filter data and location
var images = s2.filterDate('2016-02-01', '2016-03-31')
                     .filterBounds(Ca);

Question 4: print the image collection you just created. What is the Temporal resolution of Sentinel 2 for your area?

Step 6: Apply the function below to remove the clouds.

// cloudMask
function cloudMask(im) {
  // Opaque and cirrus cloud masks cause bits 10 and 11 in QA60 to be set,
  // so values less than 1024 are cloud-free
  var mask = ee.Image(0).where(im.select('QA60').gte(1024), 1).not();
  return im.updateMask(mask);
}

// remove clouds for all images
images = images.???(cloudMask);

Step 7: Add the map with true colors.

// Add to map
Map.centerObject(NgheAn, 8);
Map.addLayer(images.min().clip(NgheAn), {bands: ['??', '??', '??'], max: 2048}, 's2 image Feb-Mar 2016');

Step 8: Calculate the NDWI from Sentinel.

// calculate ndwi from sentinel
function s2ndwi(img){
  var ndwi = img.normalizedDifference(['??', '??']).rename('NDWI');
  return img.addBands(ndwi);
}
// run ndwi on all images
images = images.map(??);

Step 9: Select the maximum value in the image Collection:

// select maximum NDWI
var s2ndwi = images.select("NDWI").??;

Step 10: Select all pixels greater than 0.1

// set the threshold
var THRESHOLD = 0.1;
// select pixels greater than threshold
s2ndwi = s2ndwi.gt(THRESHOLD);

Step 11:  Add the map to the canvas.

// set visualization
var ndwi_viz = {bands:"NDWI", min:??, max:??, palette:"000000,0000FF"};
// add the map as a layer
Map.addLayer(s2ndwi.updateMask(s2ndwi).clip(NgheAn), ndwi_viz , 'ndwi');

Question 6:  Run the code also for a different period. What differences you observe?

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