Detecting the changes of NDVI  between two years for a given area from Landsat 8 imagery


The solution is provided as follow. One can simply copy the code and paste in GEE code editor from each sub-section.

  • Find the location based on the given coordinates:

// To find the images that are available in a specific date in a specific time, we need to create an image collection first. 

// The image collection can filtered with location of the points and dates of two time periods. 
// In this example, I have chosen first image during the month of July in 2014 and 2017
// // Creating Image Collection of July 2014
var imageCol2014 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterBounds(ee.Geometry.Point(-71.5265, 41.4715)) // South Kingstown 
    .filterDate('2014-07-01', '2014-07-30');
// // Creating Image Collection of July 2017
var imageCol2017 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterBounds(ee.Geometry.Point(-71.5265, 41.4715)) // South Kingstown 
    .filterDate('2017-07-01', '2017-07-30');

// Checking the image collection 
  •  Separate the first image from the image collection  :

// The first image can be selected with .first() command. However, to do with more flexible calling of
// an image from a image collection, I did it with list.

// Converting the list and selecting the first image
// for 2014
var listCol2014 = imageCol2014.toList(50)
var img2014 = ee.Image(listCol2014.get(0))
// for 2017
var img2017 = ee.Image(imageCol2017.first())

// Checking the image
  •  Calculate the NDVI

// NDVI can be calculated in many ways. Best and simple method is to use .normalizedDifference function
// But, I just want to use other method, which can be useful in many application.

// NDVI can be calculated using expression
// // NDVI for 2014
var ndvi2014 = img2014.expression(
'(NIR - RED) / (NIR + RED)' , {
'NIR' :'B4'),
'RED' :'B3')
} ) ;

// NDVI can be calculated using math operation
// // NDVI for 2017
var ndvi2017 ='B4').subtract('B3'))
  • Plotting the difference between two years

// Load the land mask from the SRTM DEM.
var landMask = ee.Image('CGIAR/SRTM90_V4').mask();

// Analyzing the difference
var ndviChange = ndvi2017.subtract(ndvi2014);

// Updating the land mask
var ndviUp = ndviChange.updateMask(landMask);

// Ploting in map layer
Map.centerObject(ndvi2017, 9);
Map.addLayer(ndviUp, { min:-0.3, max: 0.3, palette: [ 'FFFFFF', '0000FF', 'FF0000']}, "Changes of NDVI  from 2014 to 2017" ));

Leave a Reply

Your email address will not be published. Required fields are marked *