Using Google Earth Engine for Remote Sensing

Google Earth Engine (GEE) is a powerful cloud-based platform for planetary-scale environmental data analysis. This guide will walk you through using GEE to analyze NDVI (Normalized Difference Vegetation Index) for drought and non-drought years in the Palouse region.

Getting Started with Google Earth Engine

  1. Sign Up and Access:

  2. Interface Overview:

    • The GEE Code Editor includes sections for writing and running JavaScript code, an interactive map for visualization, and various panels for asset management, output display, and error logging.

Get Started with Earth Engine*―*Source

Key Concepts

  1. Datasets:

    • GEE hosts a variety of datasets, including Landsat, Sentinel, MODIS, and more. These datasets cover a range of applications from land cover and land use analysis to climate and environmental monitoring.
  2. Scripting with JavaScript:

    • GEE uses JavaScript for scripting. Users write scripts to process and analyze geospatial data. Python can also be used via the Earth Engine Python API for more complex integrations.
  3. Filtering and Visualization:

    • Filtering: Select specific datasets, time ranges, and geographic areas using methods like .filterDate(), .filterBounds(), etc.

    • Visualization: Use .addLayer() to display data on the map.

Example Workflow

Here's a step-by-step guide to analyzing NDVI for the Palouse region during drought and non-drought years:

1. Define the Study Area

// Define the study area (Palouse region)
var studyArea = ee.Geometry.Polygon([
  [-117.5, 46.5], 
  [-116.5, 46.5], 
  [-116.5, 47.5], 
  [-117.5, 47.5], 
  [-117.5, 46.5]
]);

2. Define the Function to Calculate NDVI

// Define a function to calculate NDVI
function calculateNDVI(image) {
  var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
  return ndvi;
}

3. Define Date Ranges for Drought and Non-Drought Years

// Define the date ranges
var droughtYear = ee.DateRange('2015-06-01', '2015-09-30');
var nonDroughtYear = ee.DateRange('2014-06-01', '2014-09-30');

4. Load Landsat 8 Imagery for Both Years

// Load Landsat 8 imagery for the drought year
var droughtImages = ee.ImageCollection('LANDSAT/LC08/C02/T1')
                      .filterBounds(studyArea)
                      .filterDate(droughtYear)
                      .sort('CLOUD_COVER');

// Load Landsat 8 imagery for the non-drought year
var nonDroughtImages = ee.ImageCollection('LANDSAT/LC08/C02/T1')
                         .filterBounds(studyArea)
                         .filterDate(nonDroughtYear)
                         .sort('CLOUD_COVER');

5. Calculate NDVI for Both Years

// Calculate NDVI for the drought year
var ndviDrought = droughtImages.map(calculateNDVI).median();

// Calculate NDVI for the non-drought year
var ndviNonDrought = nonDroughtImages.map(calculateNDVI).median();

6. Visualize NDVI on the Map

// Visualize NDVI on the map
var visParams = {
  palette: ['red', 'yellow', 'green'], // Red to green palette
  min: -1,
  max: 1
};

Map.centerObject(studyArea, 9);
Map.addLayer(ndviDrought, visParams, 'NDVI Drought Year');
Map.addLayer(ndviNonDrought, visParams, 'NDVI Non-Drought Year');

7. Export NDVI Results

// Export NDVI Drought Year
Export.image.toDrive({
  image: ndviDrought.toFloat(),
  description: 'NDVI_Drought_Year',
  scale: 30,  // Adjust the scale as needed
  region: studyArea,
  folder: 'GEE',  // Specify your folder in Google Drive
  maxPixels: 1e10  // Adjust the maxPixels as needed
});

// Export NDVI Non-Drought Year
Export.image.toDrive({
  image: ndviNonDrought.toFloat(),
  description: 'NDVI_Non_Drought_Year',
  scale: 30,  // Adjust the scale as needed
  region: studyArea,
  folder: 'GEE',  // Specify your folder in Google Drive
  maxPixels: 1e10  // Adjust the maxPixels as needed
});

8. Additional Visualization - False Color Composite

// Load an image for false color composite
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_043027_20140802');

// Define the visualization parameters
var vizParams = {
  bands: ['B5', 'B4', 'B3'],
  min: 0,
  max: 0.5,
  gamma: [0.95, 1.1, 1]
};

// Center the map and display the image
Map.addLayer(image, vizParams, 'False Color Composite');

9. Listing Image IDs in the Collection

// Load an image collection
var imageCollection = ee.ImageCollection('LANDSAT/LC08/C02/T1')
                         .filterBounds(studyArea)
                         .filterDate(nonDroughtYear)
                         .sort('CLOUD_COVER');

// Get the image IDs in the collection
var imageIDs = imageCollection.aggregate_array('system:index');

// Print the image IDs
print('Image IDs:', imageIDs);

Did you find this article valuable?

Support Shashwot Niraula blog by becoming a sponsor. Any amount is appreciated!