Calculating NDVI Using MODIS in Google Earth Engine

SHARE:

Learn how to calculate and visualize NDVI using MODIS MOD09GA in Google Earth Engine. Step-by-step tutorial with code and use cases.

Calculating NDVI Using MODIS in Google Earth Engine. Understanding vegetation health is crucial for various environmental monitoring and agricultural applications. The Normalized Difference Vegetation Index (NDVI) is a widely used and simple yet powerful indicator that quantifies the greenness of vegetation using satellite imagery. This article will guide you through a Google Earth Engine (GEE) script that calculates the NDVI from MODIS satellite data, providing a practical example of how remote sensing can be used to assess vegetation conditions. Whether you're an environmental scientist, an agriculture enthusiast, or simply curious about Earth observation, this example demonstrates a fundamental technique in analyzing our planet's green cover.

NDVI MODIS preview in Google Earth Engine

What This Script Does

This Google Earth Engine script performs a straightforward calculation of the Normalized Difference Vegetation Index (NDVI) using a single image from the MODIS (Moderate Resolution Imaging Spectroradiometer) collection. The script loads a specific MODIS surface reflectance image, extracts the Near-Infrared (NIR) and Red bands (which are highly sensitive to vegetation), and then applies the NDVI formula. The resulting NDVI values, ranging from -1 to +1, are then visualized on a map using a custom color palette, where higher values indicate denser and healthier vegetation, and lower values suggest sparse or stressed vegetation, or even non-vegetated surfaces. This script provides a clear and concise illustration of how to leverage GEE's capabilities for basic vegetation analysis.

This script demonstrates how to compute NDVI using a single MODIS image using GEE’s built-in .normalizedDifference() function. Specifically, it loads a MODIS surface reflectance image for March 9, 2012, and computes NDVI using the near-infrared (NIR) and red bands.

The NDVI is calculated using the formula:

NDVI=(NIRRED)/(NIR+RED)

Where:

  • NIR = Band 2 (sur_refl_b02) [841–876 nm]

  • RED = Band 1 (sur_refl_b01) [620–670 nm]

It then centers the map over Kansas, USA, and displays both a true-color composite and the computed NDVI using a rich green-brown color palette for better interpretation.

Google Earth Engine (GEE) Code Sample



// The input image to reduce, in this case an SRTM elevation map.
var image = ee.Image('CGIAR/SRTM90_V4');

// The region to reduce within.
var poly = ee.Geometry.Rectangle([-109.05, 41, -102.05, 37]);

// Reduce the image within the given region, using a reducer that
// computes the max pixel value.  We also specify the spatial
// resolution at which to perform the computation, in this case 200
// meters.
var max = image.reduceRegion({
  reducer: ee.Reducer.max(),
  geometry: poly,
  scale: 200
});

// Print the result (a Dictionary) to the console.
print(max);

Step-by-Step Explanation:

  1. // NormalizedDifference example. and subsequent comments: These are comments providing context and explaining the purpose of the script, including the NDVI formula and the specific MODIS bands used for Red and Near-Infrared (NIR).
  2. var img = ee.Image('MODIS/006/MOD09GA/2012_03_09');: This line loads a specific image from the MODIS Surface Reflectance Daily Global 500m (MOD09GA) collection. The identifier 'MODIS/006/MOD09GA' specifies the dataset, and '2012_03_09' selects the image captured on March 9, 2012. The loaded image is stored in a variable named img.
  3. var ndvi = img.normalizedDifference(['sur_refl_b02', 'sur_refl_b01']);: This is the core of the NDVI calculation.
    • img.normalizedDifference(): This is a built-in Google Earth Engine function that calculates the normalized difference between two bands of an image.
    • ['sur_refl_b02', 'sur_refl_b01']: This is an array specifying the names of the two bands to be used in the calculation.
      • 'sur_refl_b02' corresponds to the Near-Infrared (NIR) band (841-876nm) in the MOD09GA product.
      • 'sur_refl_b01' corresponds to the Red band (620-670nm) in the MOD09GA product.
    • The result of this calculation, the NDVI image, is stored in a variable named ndvi. The NDVI is calculated using the formula:

      NDVI=(NIRRED)/(NIR+RED)

  4. var palette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', ... ];: This line defines a color palette as an array of hexadecimal color codes. This palette will be used to visually represent the different NDVI values on the map. White ('FFFFFF') typically represents low or negative NDVI values (e.g., clouds, water, bare soil), while shades of green ('99B718' to '011301') represent increasing levels of healthy vegetation.
  5. Map.setCenter(-94.84497, 39.01918, 8);: This line centers the map view to a specific latitude and longitude (-94.84497, 39.01918) at a zoom level of 8. This helps to focus the initial map display on an area where the MODIS image is likely to cover.
  6. Map.addLayer(img.select(['sur_refl_b01', 'sur_refl_b04', 'sur_refl_b03']), {gain: [0.1, 0.1, 0.1]}, 'MODIS bands 1/4/3');: This line adds the original MODIS image to the map for reference.
    • img.select(['sur_refl_b01', 'sur_refl_b04', 'sur_refl_b03']): This selects the Red (sur_refl_b01), Near-Infrared (sur_refl_b04 in this band combination for a common false-color composite), and Blue (sur_refl_b03) bands for visualization.
    • {gain: [0.1, 0.1, 0.1]}: This applies a gain factor to each band to enhance the visual appearance of the image.
    • 'MODIS bands 1/4/3': This is the name that will appear in the map layer control.
  7. Map.addLayer(ndvi, {min: 0, max: 1, palette: palette}, 'NDVI');: This line adds the calculated NDVI image to the map.
    • ndvi: This is the NDVI image object created earlier.
    • {min: 0, max: 1, palette: palette}: This defines the visualization parameters for the NDVI layer. It specifies that NDVI values ranging from 0 to 1 will be mapped to the colors defined in the palette. Although the theoretical range of NDVI is -1 to +1, for healthy vegetation, values typically fall between 0 and 1.
    • 'NDVI': This is the name that will appear in the map layer control for the NDVI layer.

Applications

The ability to calculate NDVI using tools like Google Earth Engine has numerous real-world applications, including:

  • Vegetation Health Monitoring: Assessing the vigor and health of forests, grasslands, and agricultural crops. Declines in NDVI can indicate stress due to drought, disease, or pest infestations.
  • Agricultural Management: Monitoring crop growth stages, estimating biomass, and assessing the impact of irrigation and fertilization practices.
  • Drought Assessment: Identifying areas affected by drought by observing reductions in vegetation greenness over time.
  • Land Cover Change Detection: Monitoring changes in vegetation cover due to deforestation, reforestation, or natural disturbances like fires.
  • Urban Vegetation Analysis: Studying the distribution and health of urban green spaces and their impact on the urban environment.
  • Ecosystem Monitoring: Tracking changes in ecosystem productivity and phenology (the timing of biological events like leaf emergence and senescence).
  • Fire Severity Assessment: Evaluating the impact of wildfires on vegetation by comparing pre- and post-fire NDVI values.

Visualization Example

Unfortunately, I cannot directly embed interactive Google Earth Engine maps or applications within this HTML code for Blogger. However, you can include a static screenshot of the NDVI visualization you obtain in the GEE Code Editor. To do this:

  1. Run the script in the Google Earth Engine Code Editor.
  2. Once the NDVI layer is displayed on the map, adjust the zoom and pan to show a relevant area.
  3. Take a screenshot of the map.
  4. Upload the screenshot to your Blogger post using the image upload tool.
  5. You can then insert the image here with a descriptive alt text.

Here is a preview of what it might look like:

NDVI MODIS preview in GEE

Once run in the Earth Engine Code Editor, this script will render:

  • true-color MODIS composite (bands 1/4/3)

  • An NDVI layer with a continuous green scale representing vegetation density:

    • Values close to 0 → bare soil or sparse vegetation

    • Values closer to 1 → dense and healthy vegetation

    • Negative values → water bodies, clouds, or snow

Notes

  • Customization: You can easily change the date in the ee.Image() function to analyze NDVI for different time periods. Exploring time series of NDVI can reveal important trends in vegetation health.
  • Region of Interest: To focus on a specific geographic area, you can define a Region of Interest (ROI) using geometric tools in the GEE Code Editor and then filter or clip the MODIS image to that region.
  • NDVI Range: While the script visualizes NDVI from 0 to 1, be aware that the theoretical range is -1 to +1. Negative values typically represent non-vegetated surfaces like water, snow, or clouds.
  • Atmospheric Correction: The MOD09GA product is a surface reflectance product, meaning it has undergone atmospheric correction. This is crucial for accurate NDVI analysis.

References



Prepared by: Jamal Chaaouan | GEE Academy @ GeoJamal.com

COMMENTS

Name

CHIRPS,1,Climate,1,Cloud masking,1,DEM,1,EVI,3,Export,2,Fire forest,1,Forest,1,GEE,1,GEE Academy,3,GEE script,1,Image analysis,6,JRC,1,Landsat,1,LST,1,MODIS,4,NDVI,5,NOAA,1,remote sensing,2,Sentinel,2,Sentinel-2,1,Snow,1,SRTM,3,temperature,1,time series,1,vegetation index,3,VIIRS,1,
ltr
item
GEE Academy: Calculating NDVI Using MODIS in Google Earth Engine
Calculating NDVI Using MODIS in Google Earth Engine
Learn how to calculate and visualize NDVI using MODIS MOD09GA in Google Earth Engine. Step-by-step tutorial with code and use cases.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTt_m2TgJof7FtziPmy7rq77kto2znfCmpC7nQBGdy5yzbIbfh5CTZ0Je3PvPuucSxWa_wg5caaUoQla_eD9RHCxKRG7EtzPY-Uk-06dx5qfCfFp1VE8-HSYo_WvYm6vb9ZJYyxb3FUPelLD5F2bLVUTKdGOvtO7DceQG9DqQOGEp3U1Q-VMnbgKw8G6E/w640-h394/NDVIMODISGEE.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTt_m2TgJof7FtziPmy7rq77kto2znfCmpC7nQBGdy5yzbIbfh5CTZ0Je3PvPuucSxWa_wg5caaUoQla_eD9RHCxKRG7EtzPY-Uk-06dx5qfCfFp1VE8-HSYo_WvYm6vb9ZJYyxb3FUPelLD5F2bLVUTKdGOvtO7DceQG9DqQOGEp3U1Q-VMnbgKw8G6E/s72-w640-c-h394/NDVIMODISGEE.png
GEE Academy
https://gee.geojamal.com/2025/04/calculating-ndvi-using-modis-in-google.html
https://gee.geojamal.com/
https://gee.geojamal.com/
https://gee.geojamal.com/2025/04/calculating-ndvi-using-modis-in-google.html
true
3421025227311197355
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content