3 Calculate NDVI

The function normalizedDifference() can be used to calculate different indices like NDVI and NDWI. You just need to specify the bands to be used in the calculation. To view the available bands go to Sentinal-2, Level 1C and click on the bands tab.

\[NDVI=(NIR - R) / (NIR + R)\]

\[NDVI=(B8 - B4) / (B8 + B4) \]


// Calculate  Normalized Difference Vegetation Index (NDVI)
// 'NIR' (B8) and 'RED' (B4)
var ndvi = clipped.normalizedDifference(['B8', 'B4']).rename(['ndvi']);

var ndviVis = {min:0, max:1, palette: ['white', 'green']}

Map.addLayer(ndvi, ndviVis, 'ndvi')

3.1 Export raster as a geotif



var exportImage = ndvi

Export.image.toDrive({
    image: exportImage,
    description: 'Calling_Lake_NDVI',
    folder: 'GEE_class',
    fileNamePrefix: 'calling_lake_NDVI',
    region: study_area,
    scale: 20,
    maxPixels: 1e9
})

Click on the tasks tab and run the unsubmitted task.

A pop up will appear which will allow you to change the file format and the save location in your Google Drive. Select GEO_TIFF and click run.

It may take time depending on the size of the file, but the GEO_TIFF file will appear in your Drive destination folder.

3.2 Extracting data to polygons within GEE

Create a buffer around the Calling Lake points


var bufferPoints = function(feature) {
  return feature.buffer(200);   // substitute in your value of Z here
};

var SS_buffer = CL_SS.map(bufferPoints);

var buffVis = SS_buffer.style({
  color: 'd541df',
  width: 2,
  fillColor: '99f13c10',  // with alpha set for partial transparency
});


Map.addLayer(buffVis, null, 'Buffered stations');

Summarize NDVI values to bufferd points

You can get different summary statistics using the reducer function. We compute the mean NDVI in each buffered polygon using ‘ee.Reducer.mean’


var pts_ndvi = ndvi.reduceRegions({
  collection: SS_buffer,
  reducer: ee.Reducer.mean(),
  scale: 10
})

print(pts_ndvi)

You can explore the feature collection in the console.

Or export as CSV file to a Google Drive folder.

//== Export to Google drive 
 Export.table.toDrive({
   collection: pts_ndvi,
   description: 'calling_lake_ndvi',
   fileFormat: 'CSV',
   folder: 'GEE_class',
 });