Time-lapse: Animate 30m Landsat images generated 90th percentile Annual NDVI from 1999 to 2018 (Study Area: South America)

Study Area

South America is a continent in the Western Hemisphere, mostly in the Southern Hemisphere, with a relatively small portion in the Northern Hemisphere. It may also be considered a subcontinent of the Americas, which is how it is viewed in the Spanish and Portuguese-speaking regions of the Americas. The reference to South America instead of other regions (like Latin America or the Southern Cone) has increased in the last decades due to changing geopolitical dynamics (in particular, the rise of Brazil). It is bordered on the west by the Pacific Ocean and on the north and east by the Atlantic OceanNorth America and the Caribbean Sea lie to the northwest. It includes twelve sovereign states (ArgentinaBoliviaBrazilChileColombiaEcuadorGuyanaParaguayPeruSurinameUruguay, and Venezuela), a part of France (French Guiana), and a non-sovereign area (the Falkland Islands, a British Overseas Territory though this is disputed by Argentina). In addition to this, the ABC islands of the Kingdom of the NetherlandsTrinidad and Tobago, and Panama may also be considered part of South America.

Study Area: South America

Know your Data

USGS Landsat 8 Collection 1 Tier 1 and Real-Time data TOA Reflectance

Landsat 8 Collection 1 Tier 1 and Real-Time data calibrated top-of-atmosphere (TOA) reflectance. Calibration coefficients are extracted from the image metadata. See Chander et al. (2009) for details on the TOA computation. The Landsat 8 images are of 30 m and 16 days spatial and temporal resolutions respectively.

USGS Landsat 7 Collection 1 Tier 1 TOA Reflectance

Landsat 7 Collection 1 Tier 1 calibrated top-of-atmosphere (TOA) reflectance. Calibration coefficients are extracted from the image metadata. See Chander et al. (2009) for details on the TOA computation. The Landsat 7 images are of 30 m and 16 days spatial and temporal resolutions respectively.

Normalized Difference Vegetation Index (NDVI)

The first is the Normalized Difference Vegetation Index (NDVI) which is referred to as the continuity index to the existing National Oceanic and Atmospheric Administration-Advanced Very High-Resolution Radiometer (NOAA-AVHRR) derived NDVI.

The NDVI is calculated from these individual measurements as follows:

NDVI= (NIR-Red) \ (NIR+Red)

In this tutorial, we will learn the following things:

  • to write a function to loop through Landsat 7, and 8 images starting from 1999 through 2018.
  • to compute NDVI using NIR and Red Bands (remember Landsat 7 and Landsat 8 images have assigned different Band Numbers for NIR and Red Bands. Be careful while selecting the bands.
  • to compute 90th annual NDVI
  • animate the NDVI throughout the study peroid

Here is the code:

// Select your country
var countries = ee.FeatureCollection("ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw")
var country_name = ['Brazil']
//var roi = countries.filter(ee.Filter.inList('Country', country_name));
var projection = 'EPSG:3857'
Map.addLayer(roi,{},"Study Area"+country_name);
Map.centerObject(roi,4);  //Zoom to Study area

//==================================//
// LANDSAT NDVI COMPOSITE CREATION //
//==================================//

// NDVI Functions
/*These 2 functions are used to calculate the NDVI for Landsat 5/7 and Landsat 8, respectively.*/
var getNDVI57 = function(image) {
  var ndvi = image.normalizedDifference(['B4', 'B3']);
  return(ndvi);  
};
var getNDVI8 = function(image){
  var ndvi = image.normalizedDifference(['B5', 'B4']);
  return(ndvi); 
 
};
// Main function
var createNDVIComposite = function(){
  var yearrangeStart = 1999;
  var yearrangeStop = 2018;
  var imgList = [];
  for(var loopYear = yearrangeStart; loopYear <= yearrangeStop; loopYear +=1){
    var start = ee.Date.fromYMD(loopYear, 1, 1);
    var end = ee.Date.fromYMD(loopYear, 12, 31);
  
    //Landsat 8
    var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR") 
      .filterBounds(roi) 
      .filterDate(start, end) 
      .filterMetadata('CLOUD_COVER', 'less_than', 80) 
      .map(getNDVI8);
    
    //Landsat7
    var l7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR") 
      .filterBounds(roi) 
      .filterDate(start, end) 
      .filterMetadata('CLOUD_COVER', 'less_than', 80) 
      .map(getNDVI57);
    
    //Landsat5
    var l5 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR")
      .filterBounds(roi)
      .filterDate(start, end)
      .filterMetadata('CLOUD_COVER', 'less_than', 80)
      .map(getNDVI57);

    //Merge collections
    var mergedCollection = ee.ImageCollection(l8.merge(l7).merge(l5))
                            .reduce(ee.Reducer.median())
                            .reduce(ee.Reducer.percentile([90]));

    var finalOutput = mergedCollection.clip(roi).rename(loopYear.toString());

    imgList.push(finalOutput);
    //Generate filename for export
    var filename = ("Annual_NDVI_"+country_name+"_").concat(loopYear.toString());
  }
 
  // Visualization parameters.
  //var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
  var args = {
    crs:'EPSG:3857',
    dimensions: '300',
    region: roi,
    min: -1, 
    max: 1, 
    //palatte: [ndviParams],
    palette: ['blue', 'white','green',' red'],
    framesPerSecond: 2,
  };

  var yearImgCol = ee.ImageCollection.fromImages(imgList);
  
  var thumb = ui.Thumbnail({
    // Specifying a collection for "image" animates the sequence of images.
    image: yearImgCol,
    params: args,
    style: {
      position: 'bottom-right',
      width: '320px'
    }});
  Map.add(thumb);
}

//-----------------------------------// 
// MAIN FUNCTION EXECUTION // 
//-----------------------------------// 
var comp = createNDVIComposite();
Timelapse

1 thought on “Time-lapse: Animate 30m Landsat images generated 90th percentile Annual NDVI from 1999 to 2018 (Study Area: South America)”

  1. Dear Dinesh…

    The code above, gives an error:

    Setting the CRS, geodesic, or evenOdd flag on a computed Geometry is not supported. Use Geometry.transform().

    i add a line after :

    var countries = ee.FeatureCollection(“ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw”)
    var country_name = [‘Brazil’]
    var roi = countries.filter(ee.Filter.inList(‘Country’, country_name));
    var projection = ‘EPSG:3857’

    var roi = roi.geometry();

    And it is works now…

Leave a Reply

%d bloggers like this: