calculate NDVI from sentinel-2

Determine the density of green on a patch of land.

Normalized Difference Vegetation Index (NDVI) quantifies vegetation by measuring the difference between near-infrared (which vegetation strongly reflects) and red light (which vegetation absorbs).

Step 1: import two sentinel-2 images

// import images
var march = ee.Image("COPERNICUS/S2/20180324T050601_20180324T050601_T44NNP");
var july = ee.Image("COPERNICUS/S2/20180722T050601_20180722T050604_T44NNP");

Step 2: calculate the ndvi

// import images
// calculate ndvi
var ndviMarch = march.normalizedDifference(["??","??"]);
var ndvijuly = july.normalizedDifference(["??","??"]);

Step 3: add images to the map

Map.addLayer(march,{min:0,max:3000,bands:"B4,B3,B2"},"rgb  March");
Map.addLayer(july,{min:0,max:3000,bands:"B4,B3,B2"},"rgb July");

Map.addLayer(ndviMarch,{min:0,max:1,palette:"??,??,??,??"},"ndvi March");
Map.addLayer(ndvijuly,{min:0,max:1,palette:"??,??,??,??"},"ndvi july");

2 comments

Leave a Reply