GEE Tutorials

Google Earth Engine Tutorial: Calculate SAVI with Landsat 8

Credit: Youtube Channel “Terra Spatial, Tutorial on calculating Soil Adjusted Vegetation Index using Landsat 8 imagery for vegetation analysis.”

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

Data Access and Preparation

To calculate SAVI (Soil Adjusted Vegetation Index) with Landsat 8 data in Google Earth Engine, first ensure you have access to the appropriate dataset. Landsat 8 Collection 1 Tier 1 (T1_TOA) provides top-of-atmosphere reflectance data, which is essential for accurate index calculation. Use the following code to load the dataset:

var dataset = ee.Image('LANDSAT/LC08/C01/T1_TOA');

Filter the dataset for the desired date range and location, and select a specific image. For example:

var image = dataset.filterDate('2023-01-01', '2023-12-31')
  .filter(ee.Filter.geometry(ee.FeatureCollection('FAO/GAUL/2015/level0')))
  .first();

SAVI Calculation in Google Earth Engine

The formula for SAVI is: (NIR – Red) / (NIR + Red + L) * (1 + L), where L is the soil adjustment factor. For most applications, L is set to 0.5. Here’s how to implement it:

var red = image.select('SR_B4');
var nir = image.select('SR_B5');
var L = 0.5;
var savi = nir.subtract(red).divide(nir.add(red).add(L)).multiply(1 + L);

This creates a SAVI image with a single band. To enhance visualization, use specific min and max values for the band:

var saviVis = {min: -1, max: 1, palette: ['green', 'yellow', 'red']};
Map.addLayer(savi, saviVis, 'SAVI');

Cloud and Water Masking

Clouds and water bodies can affect SAVI accuracy. Use the pixel_qa band to mask these. Include the following code:

var qa = image.select('pixel_qa');
var cloudMask = qa.bitwiseAnd(1 << 3).eq(0);
var waterMask = image.select('SR_B1').lt(0.05);
var finalMask = cloudMask.and(waterMask);
var saviMasked = savi.updateMask(finalMask);

Example Output

The final SAVI image will highlight vegetation health. Adjust the visualization parameters, such as palette and min/max values, to better interpret results. To export the image, use:

Export.image.toDrive({
  image: saviMasked,
  description: 'SAVI_Export',
  folder: 'GEE_Exports',
  fileNamePrefix: 'savi',
  region: geometry,
  scale: 30,
  maxPixels: 1e10
});

FAQ

  • What if I need a different L value for my area?

    You can modify the L variable to a value suitable for local soil conditions, typically determined through calibration studies. For example: var L = 0.8;

  • Can SAVI be calculated with other sensors?

    Yes, but ensure equivalent bands (e.g., red and near-infrared) are used. Adjust the band names according to the sensor's specifications.

  • Why use Landsat 8 for SAVI?

    Landsat 8 provides high-resolution, multi-spectral data with consistent band coverage, making it ideal for vegetation analysis and SAVI calculation.

  • How do I visualize the SAVI result effectively?

    Use the palette parameter to define color ranges. A common range is [-1, 1], with colors like green (high vegetation) to red (low vegetation).

  • How do I handle errors in the code?

    Check for syntax issues, ensure correct band names, and verify that the geometry is properly defined. Use print() or Map.addLayer() to debug intermediate steps.

  • What is the purpose of the pixel_qa band?

    The pixel_qa band contains quality assessment bits. Using it helps identify and exclude clouds, snow, and water from the analysis.

  • Can I calculate SAVI for multiple images?

    Yes, use map() to apply the SAVI formula across a collection of images. Replace the first() method with map() and process each image iteratively.

Similar Posts

Leave a Reply

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