VEGETATION ANALYSIS : NDVI CALCULATION ON GOOGLE EARTH ENGINE

PETER NDIRITU THUKU
4 min readMay 18, 2023

--

Google Earth Engine is a cutting-edge platform that integrates GIS and remote sensing to provide a comprehensive toolset for geospatial analysis.
This powerful cloud-based platform allows users to access a vast array of satellite imagery and geospatial data for in-depth analysis and visualization. With Earth Engine, researchers, scientists, and policymakers can leverage advanced algorithms and tools to extract valuable insights from Earth observation data.
The platform enables users to perform tasks such as image processing, classification, change detection, and time-series analysis at scale, facilitating the monitoring and management of Earth’s resources.
By combining GIS functionalities with remote sensing capabilities, Google Earth Engine enables users to analyze and understand complex spatial relationships, track environmental changes over time, and address a wide range of global challenges, including land use planning, environmental monitoring, disaster management, and sustainable development.

NDVI Calculation on GEE

NDVI (Normalized Difference Vegetation Index) calculation on Google Earth Engine (GEE) using Sentinel-2 imagery allows for the assessment of vegetation health and density at a high spatial resolution. Sentinel-2 is a satellite sensor that captures multispectral imagery, making it well-suited for NDVI analysis.

NDVI is calculated using the formula = (NIR — Red) / (NIR + Red).

Workflow or Methodology:

In GEE, NDVI calculation involves the following steps:
Data Acquisition: GEE provides access to Sentinel-2 imagery, which includes multiple spectral bands at different wavelengths. These bands capture information in the visible, near-infrared, and shortwave infrared regions of the electromagnetic spectrum.

Map.addLayer(KIAMBU);
Map.centerObject(KIAMBU,10);

Image Selection: Users can filter and select specific Sentinel-2 images based on their study area and desired time period. GEE offers a vast collection of Sentinel-2 imagery, ensuring availability of data for analysis.

var filtered = sentinel2.filter(ee.Filter.bounds(KIAMBU))
.filter(ee.Filter.date('2020-01-01', '2020-12-31'))
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10));

Band Extraction: The near-infrared (NIR) and red spectral bands of Sentinel-2 imagery are extracted. These bands are crucial for calculating NDVI.

var rgbVis = {min: 0.0, max: 3000, bands: ['B4', 'B3', 'B2']};

Radiometric Calibration: To account for atmospheric conditions and sensor-specific characteristics, the Sentinel-2 imagery may undergo radiometric calibration. GEE automatically handles this calibration process, ensuring accurate and reliable NDVI results.

var newmerge_median = filtered.median()
//displaying layer

var newmerge_clip = newmerge_median.clip(KIAMBU);
Map.addLayer( newmerge_clip,rgbVis);

NDVI Computation: NDVI is calculated using the formula: (NIR — Red) / (NIR + Red). GEE applies this formula to each pixel of the selected Sentinel-2 imagery, generating an NDVI image where each pixel represents the corresponding NDVI value.

// Write a function that computes NDVI for an image and adds it as a band
function addNDVI(image) {
var ndvi = image.normalizedDifference(['B8', 'B4']).rename('ndvi');
return image.addBands(ndvi);
}

// Map the function over the collection
var withNdvi = filtered.map(addNDVI);

var composite = withNdvi.median();

var ndviComposite = composite.select('ndvi').clip(KIAMBU);

var palette = [
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301'];

var ndviVis = {min:0, max:0.5, palette: palette };
Map.addLayer(ndviComposite, ndviVis, 'ndvi');

Time Series Analysis: GEE allows users to aggregate the NDVI values over time, creating a time series chart. The chart displays the temporal variation of NDVI values, representing the vegetation health and density changes during the selected period.

// Display a time-series chart of the mean NDVI value for the Farm region over time, using the filtered and NDVI-computed image collection
var chart = ui.Chart.image.seriesByRegion({
imageCollection: withNdvi.select('ndvi'),
regions: KIAMBU,
reducer: ee.Reducer.mean(),
scale: 10,
seriesProperty: 'label', // add a series property to differentiate the regions
xProperty: 'system:time_start' // specify the x-axis as the image time
})
.setOptions({
lineWidth: 1,
title: 'NDVI Time Series',
interpolateNulls: true,
vAxis: {title: 'NDVI'},
hAxis: {title: '', format: 'YYYY-MMM'}
});
print(chart);

Visualization and Analysis: Users can visualize the NDVI image on GEE by creating color-coded maps that highlight different vegetation densities. High NDVI values indicate healthier and denser vegetation, while low values correspond to sparse or non-vegetated areas. This visualization aids in assessing vegetation conditions and identifying areas of interest for further analysis.

Kiambu County, Kenya

The time series chart can be visualized within GEE, showing the NDVI values on the y-axis and the corresponding time steps on the x-axis. This visualization provides an overview of the vegetation dynamics and enables the identification of seasonal patterns, trends, or anomalies in vegetation growth.

NDVI Chart

--

--

PETER NDIRITU THUKU

GIS & RS | Geospatial Developer | EOS - Spatial Data Science | Surveying | Python | JS | GeoAI & ML | Tel: +254 113143372 | Email : thukupeter487@gmail.com