GEE Tutorials

Google Earth Engine Tutorial: Find Monthly NDVI Anomalies

Credit: Youtube Channel “Terra Spatial, Tutorial on calculating and visualizing monthly NDVI anomalies to detect vegetation changes and stress.”

You can see all the tutorials from here: Techgeo Academy.

Introduction to Monthly NDVI Anomalies in Google Earth Engine

NDVI (Normalized Difference Vegetation Index) is a key metric for monitoring vegetation health. Monthly NDVI anomalies highlight deviations from the typical NDVI values for a given month, useful for detecting unusual vegetation conditions. This tutorial demonstrates how to calculate and visualize these anomalies using Google Earth Engine (GEE).

Prerequisites

Ensure you have access to GEE and are familiar with its JavaScript API. Use the Code Editor to run the examples below.

Data Preparation

1. Load the Landsat 8 Surface Reflectance dataset: var dataset = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR");

2. Filter by date and region: var filtered = dataset.filterDate('2018-01-01', '2023-12-31').filterBounds(region);

NDVI Calculation

Compute NDVI using near-infrared (NIR) and red bands: var ndvi = filtered.select(['SR_B5', 'SR_B4']).map(function(image) { return image.expression('(NIR - RED)/(NIR + RED)', {NIR: image.select('SR_B5'), RED: image.select('SR_B4')}); });

Baseline Period and Monthly Aggregation

1. Define a baseline period (e.g., 2013-2018): var baseline = ndvi.filterDate('2013-01-01', '2018-12-31');

2. Calculate monthly mean for the baseline: var baselineMonthly = baseline.map(function(image) { return image.set('month', ee.Number(image.get('system:time_start')).get('month')); }).reduce(ee.Reducer.mean());

Anomaly Calculation

1. Extract the study period data (e.g., 2019-2023): var study = ndvi.filterDate('2019-01-01', '2023-12-31');

2. Compute anomalies by subtracting baseline monthly means: var anomalies = study.map(function(image) { var month = ee.Number(image.get('month')); return image.select('ndvi').subtract(baselineMonthly.select('ndvi').get('month', month)); });

Visualization

Display the mean NDVI and anomalies: Map.addLayer(ndvi.mean(), {min: -1, max: 1, palette: ['red', 'green']}, 'Mean NDVI'); Map.addLayer(anomalies.mean(), {min: -0.5, max: 0.5, palette: ['blue', 'white', 'red']}, 'NDVI Anomalies');

Exporting Results

Export the anomaly layer to your Google Drive: Export.image.toDrive({ image: anomalies, description: 'NDVI_Anomalies', folder: 'GEE_Exports', fileNamePrefix: 'monthly_anomalies', region: region.geometry(), scale: 30 });

FAQ

How do I choose the baseline period?

The baseline period is typically a long time span (e.g., 30 years) to capture seasonal trends. Adjust the date range in filterDate() to match your study area requirements.

Can I use other satellite data for NDVI?

Yes. Replace the dataset with any other source (e.g., Sentinel-2, MODIS) and adjust the band selection accordingly.

What if my dataset has missing values?

GEE automatically handles gaps in image collections. You can also filter clouds using the qualityMasks function in the dataset’s documentation.

How to visualize anomalies for a specific month?

Use filter(ee.Filter.eq('month', value)) to isolate a particular month and display it with the same visualization settings.

Can I calculate anomalies for a custom region?

Yes. Define the region using a geometry (e.g., geometry = ee.Geometry.Polygon([[...]]);) and apply it in all filtering and export steps.

Similar Posts

Leave a Reply

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