15.4 C
Nairobi
Friday, September 30, 2022

Computing MNDWI using Sentinel on GEE

What is MNDWI?

Modified Normalized Difference Water Index (MNDWI) is a spectral index used to analyze water bodies such as rivers, lakes and dams especially in built-up areas since it can reduce or even remove built-up land. This index uses two bands:  green and short-wave infrared (SWIR). MNDWI values range from -1 to +1 where the negative values represent areas with no water bodies and positive values >0.5 represent water bodies. As I have shown on how to compute NDBI in GEE, this article focuses on step by step process of computing MNDWI using Sentinel 2 on Google Earth Engine.

Select an Area of Interest

You can choose an area of interest by importing a shapefile of the region you are interested in. To achieve this, proceed as follows:

  1. On the left side panel, click on Assets
  2. A list of your previously ingested tables (shapefiles) will appear
  3. Navigate to your shapefile of interest and click on the arrow to import the shapefile into the script.
Google Earth Engine

Select an image collection

  1. In this case, an image from Sentinel 2 image collection from Copernicus was used. Perform a filter for the clouds so as to obtain an image with a less cloud cover.
  2. Proceed to perform a filter for the dates, to obtain the date the image was acquired and a filter for bounds to obtain an image for your area of interest.
  3. Reduce the image collection to a single image by calculating the median of the pixel values.
var s2 = ee.ImageCollection(“COPERNICUS/S2”);
var filtered = s2.filter(ee.Filter.lt(‘CLOUDY_PIXEL_PERCENTAGE’, 30))
		.filter(ee.Filter.date(‘2019-01-01’,  ‘2019-12-31’))
		.filter(ee.Filter.Bounds(table));
var image = filtered.mean();
print (image);

Visualization

Apply a true color visualization to the filtered image. This is achieved using B4, B3, and B2 which are Red, Green and Blue bands respectively.

var rgbVis = {
min: 0.00,
max: 3000,
bands: [‘B4’, ‘B3’, ‘B2’]
};

Calculate and  Visualize MNDWI

The MNDWI is calculated using the normalizedDifference() function and bands B11 and B3.

Apply the visualization parameters to the MNDWI layer.

var mndwi = image.normalizedDifference([‘B11’, ‘B3’).rename(‘mndwi’);
var mndwiParams = {
min: -1,
max: 1,
palette: [‘white’, ‘blue’]
};

Display the Final Result

Map.addLayer(image.clip(table), rgbVis, ‘Image’);
Map.addLayer(mndwi.clip(table), mndwiParams, ‘mndwi’);
Map.centerObject(table, 10);

Analysis

The area of interest is Nairobi County. We expect to see major water bodies such as the Nairobi River and dams be enhanced despite being surrounded by built-up areas since Nairobi is highly urbanized.

Part of Nairobi River in the Eastern side bordering Kiambu County.

close

Join Our Mailing List

Risper Mutinda
Risper Mutinda
Hello. I am Risper Mutinda. I am a passionate Web and GIS Developer but more importantly, I am passionate about Technology.

Related Articles

1 COMMENT

  1. Hi, great article!
    It was really helpflu for me!
    I had some questions, I would like to know if you could help me?!
    To calculate the MNDWI it would be necessary to resampling the SWIR band? considering that it has 20m while the green band has 10m. Will this difference not influence the result?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay Connected

933FansLike
132FollowersFollow
3,730SubscribersSubscribe
- Advertisement -

Join Our Mailing List

Latest Articles