Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Landsat 8 Normalized Difference Moisture Index - NDMI

//VERSION=3
const moistureRamps = [
        [-0.8, 0x800000],
        [-0.24, 0xff0000],
        [-0.032, 0xffff00],
        [0.032, 0x00ffff],
        [0.24, 0x0000ff],
        [0.8, 0x000080]
      ];

const viz = new ColorRampVisualizer(moistureRamps);

function setup() {
  return {
    input: ["B05", "B06","dataMask"],
    output: [
      { id: "default", bands: 4 },
      { id: "index", bands: 1, sampleType: "FLOAT32" }
    ]
  };
}

function evaluatePixel(samples) {
  let val = index(samples.B05, samples.B06); 
  // The library for tiffs works well only if there is only one channel returned.
  // So we encode the "no data" as NaN here and ignore NaNs on frontend.
  const indexVal = samples.dataMask === 1 ? val : NaN;
  return {
    default: [...viz.process(val),samples.dataMask],
    index: [indexVal] 
  };
}

Evaluate and Visualize

General description of the script

The NDMI is a normalized difference moisture index, that uses NIR and SWIR bands to display moisture. The SWIR band reflects changes in both the vegetation water content and the spongy mesophyll structure in vegetation canopies, while the NIR reflectance is affected by leaf internal structure and leaf dry matter content but not by water content. The combination of the NIR with the SWIR removes variations induced by leaf internal structure and leaf dry matter content, improving the accuracy in retrieving the vegetation water content. The amount of water available in the internal leaf structure largely controls the spectral reflectance in the SWIR interval of the electromagnetic spectrum. SWIR reflectance is therefore negatively related to leaf water content. In short, NDMI is used to monitor changes in water content of leaves, and was proposed by Gao. NDWI is computed using the near infrared (NIR) and the short wave infrared (SWIR) reflectance’s:

NDMI = (NIR - SWIR) / (NIR + SWIR)

For Landsat 8, NDMI calculates as:

NDMI = (B05 - B06) / (B05 + B06)

See also this page.

Description of representative images

The NDMI over Rome. Acquired on 2020-07-30. The script example 1