Simple Methods to calculate NDVI using simple algorithm

Load two 5-year Landsat 7 composites.

var landsat1999 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003');
var landsat2008 = ee.Image('LANDSAT/LE7_TOA_5YEAR/2008_2012');

Define Palette

var ndviParams = {min: -1, max: 1, palette: ['red', 'white', 'green']};

Compute NDVI the hard way.

var ndvi1999 ='B4').subtract('B3'))

//Add NDVI to Map
Map.addLayer(ndvi1999, ndviParams, "NDVI 1999"); 
NDVI 1999

Compute NDVI the easy way.

var ndvi2008 = landsat2008.normalizedDifference(['B4', 'B3']);

//Add NDVI to Map
Map.addLayer(ndvi2008, ndviParams, "NDVI 2008");
NDVI 2008

2 thoughts on “Simple Methods to calculate NDVI using simple algorithm”

Leave a Reply

%d bloggers like this: