GEE Tutorials

Google Earth Engine Tutorial: Calculate NDMI with Landsat 8

Credit: Youtube Channel “Terra Spatial, Learn how to calculate Normalized Difference Moisture Index for vegetation water content assessment.”

You can see all the tutorials from here: Techgeo Academy.


The Normalized Difference Moisture Index (NDMI) is a remote sensing vegetation index that relates water content within vegetation canopies. It is particularly useful for monitoring vegetation moisture stress and health. Using Google Earth Engine (GEE), you can calculate NDMI with Landsat 8 data efficiently. This tutorial provides a step-by-step guide to achieve this.

Step-by-Step Tutorial

1. Access Landsat 8 Data: Use the Landsat 8 Collection 2, Tier 1 dataset, which includes surface reflectance SWIR1 and NIR bands. Example code for fetching data:


var dataset = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
  .filterDate('2023-01-01', '2023-12-31');

2. Select Bands: NDMI is calculated using the near-infrared (band 5) and shortwave infrared (band 6) bands. Use the following code:


var ndmi = dataset.map(function(image){
  return image.select(['SR_B5', 'SR_B6']).rename(['nir', 'swir']);
});

3. Calculate NDMI: Apply the formula (NIR – SWIR) / (NIR + SWIR) to the selected bands. Here’s how to implement it:


var ndmiImage = ndmi.map(function(image){
  return image.select(['nir', 'swir']).map(function(image){
    return image.expression(
      '(nir - swir) / (nir + swir)', 
      {nir: image.select('nir'), swir: image.select('swir')}
    );
  });
});

4. Reduce Image Collection: To create a single image for analysis, apply a median reduction over the collection:


var ndmiMedian = ndmiImage.reduce(ee.Reducer.median());

5. Visualize the Result: Display NDMI on the map using appropriate visualization parameters:


Map.setCenter(-122.15, 37.77, 9);
Map.addLayer(ndmiMedian, {min: -1, max: 1, palette: ['blue', 'white', 'green']}, 'NDMI');

FAQ

What is NDMI, and why is it useful?

NDMI measures vegetation moisture content and is used to assess plant health, moisture stress, or biomass. It is a reliable index for agricultural or ecological monitoring.

Can NDMI be calculated for other sensors besides Landsat 8?

Yes, NDMI can be adapted for other satellites with similar spectral bands, such as Sentinel-2 (using band 8 and band 11) or Landsat 7.

How do I handle missing data or cloud cover?

Apply a cloud masking function or filter by quality bands before calculating NDMI. For Landsat 8, use the ‘CFmask’ band to identify and exclude cloudy pixels.

What is the correct formula for NDMI?

NDMI is calculated as (NIR – SWIR) / (NIR + SWIR). For Landsat 8, use SR_B5 (NIR) and SR_B6 (SWIR1).

Why is the visualization range set between -1 and 1?

The NDMI values typically range from -1 to 1, with higher values indicating healthier, wetter vegetation. Adjust the range if needed for specific applications.


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *