List

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

Solutions:

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
print(imageCol2014)
``````
•  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
print(img2017)
``````
•  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' : img2014.select('B4'),
'RED' : img2014.select('B3')
} ) ;

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

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

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

### 2 Responses to “Detecting the changes of Normalized Difference Vegetation Index (NDVI) using Google Earth Engine”

1. Hélio

Hey
When I get finish with my work in post graduate studies – I´m trying to comprehend the NDVI differences in my state – Sure that I´ll make reference to your site on my bibliography references.

Thank s a lot man.

2. Mohsine