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

Normalized difference vegetation index, PlanetScope

//NDVI
var val = (nir - red) / (nir + red);

return colorBlend(val,
  [0.0, 0.5, 1.0],
  [
    [1, 0, 0],
    [1, 1, 0],
    [0.1, 0.31, 0],
  ]);
//VERSION=3
//NDVI

function setup() {
  return {
    input: [{
      bands: [
        "red",
        "nir",
        "dataMask",
        "clear"
      ]
    }],
    output: [
      { id: "default", bands: 4 },
      { id: "index", bands: 1, sampleType: "FLOAT32" },
      { id: "eobrowserStats", bands: 2, sampleType: "FLOAT32" },
      { id: "dataMask", bands: 1 },
    ]
  }
}

function evaluatePixel(samples) {
  let ndvi = (samples.nir - samples.red) / (samples.nir + samples.red);
  const indexVal = samples.dataMask === 1 ? ndvi : NaN;
  const clear = samples.dataMask * samples.clear;

  let id_default = colorBlend(ndvi, [0.0, 0.5, 1.0],
    [
      [1, 0, 0, clear],
      [1, 1, 0, clear],
      [0.1, 0.31, 0, clear],
    ])

  return {
    default: id_default,
    index: [indexVal],
    eobrowserStats: [indexVal, samples.clear],
    dataMask: [samples.dataMask],
  };
}

Evaluate and visualize

As PlanetScope is commercial data, brought into Sentinel Hub as Bring Your Own Data, direct EO Browser links are not possible due to the personalized data credentials.

General description

The well known and widely used NDVI is a simple, but effective index for quantifying green vegetation. It normalizes green leaf scattering in Near Infra-red wavelengths with chlorophyll absorption in red wavelengths.

The value range of the NDVI is -1 to 1. Negative values of NDVI (values approaching -1) correspond to water. Values close to zero (-0.1 to 0.1) generally correspond to barren areas of rock, sand, or snow. Low, positive values represent shrub and grassland (approximately 0.2 to 0.4), while high values indicate temperate and tropical rainforests (values approaching 1). It is a good proxy for live green vegetation; see [1] for details.

The normalized difference vegetation index, abbreviated NDVI, is defined as

\[NDVI := \mathtt{Index}(nir,red) = \frac{nir-red}{nir+red}.\]

This is an example script which can be used with EO Browser and is configured to return statistics in a format which can be used with the statistical info chart. For more information, see How Can I Configure My Layers For Statistical Information In EO Browser?

Description of representative images

NDVI of agriculture fields in Iowa.

NDVI of agriculture fields in Iowa

References

[1] Wikipedia, Normalized Difference Vegetation Index. Accessed on October 4th 2017.