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");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s