šŸŒGEEIntermediateā±ļø 3 mins read

Introduction to Google Earth Engine (GEE)

Published by GISTECHNEWS Editorial Team • Peer-Reviewed & Verified on QGIS 3.34+ LTR & Python 3.10+

Traditional desktop GIS processing breaks down when tasked with planetary-scale questions: computing decadal surface water trends over entire continents, monitoring Amazon rainforest deforestation in real-time, or crunching petabytes of daily satellite telemetry. Google Earth Engine (GEE) is a cloud-based geospatial computing platform that pairs a multi-petabyte public data catalog (Landsat, Sentinel, MODIS, ERA5 climate data, terrain DEMs) with Google's massive parallel computing infrastructure. In this masterclass, we explore GEE's architectural paradigms, client-side vs server-side execution, and the JavaScript Code Editor API.

šŸ“‹ Prerequisites

  • A registered, approved Google Earth Engine account (earthengine.google.com).
  • Basic understanding of JavaScript syntax (variables, objects, functions).
  • Familiarity with satellite imagery bands.

šŸ› ļø Technical Environment

Required Software: Google Earth Engine Web Code Editor (Recommended: GEE Cloud API)

Practice Dataset: COPERNICUS/S2_SR_HARMONIZED Collection

Source Portal: Google Earth Engine Data Catalog

CRS / Format: Cloud Projections (EPSG:4326/3857) (Cloud-Native Earth Engine ImageCollection)

Step-by-Step Workflow & Methodological Execution

1

Module 1: The Client-Side vs Server-Side Architecture

The single most critical concept in Earth Engine is understanding that your browser is merely a lightweight client. The heavy computations happen on Google's cloud server clusters: • Server-Side Objects: Wrapped in the `ee` namespace (e.g., `ee.Number`, `ee.String`, `ee.Image`, `ee.ImageCollection`). These objects represent container proxies for instructions that run on Google's cloud. • Client-Side Objects: Native JavaScript variables (e.g., `var x = 5`). • The Golden Rule: You CANNOT use native JavaScript `for` loops or `if` statements on server-side Earth Engine objects! Attempting `for (var i=0; i < collection.size(); i++)` will crash your script. Instead, you must use functional server-side mapping: `collection.map(function(image) { ... })`.

2

Module 2: Filtering and Reducing an ImageCollection

An `ee.ImageCollection` is a multi-terabyte stack of satellite scenes. To analyze a specific area, you chain server-side filters: 1. Spatial Filter: `.filterBounds(geometry)` isolates only tiles that intersect your Area of Interest. 2. Temporal Filter: `.filterDate('2023-01-01', '2023-12-31')` restricts scenes to a specific time window. 3. Metadata Filter: `.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10))` eliminates heavily clouded scenes. 4. Composite Reducer: Combine hundreds of individual filtered tiles into a single seamless, cloud-free image using a reducer like `.median()`. GEE calculates the statistical median pixel value across the temporal stack, eliminating transient clouds and shadows automatically!

3

Module 3: Visualizing Layers and Exporting Analytics

1. Map Visualization (`Map.addLayer`): Define visualization parameter dictionaries containing band combinations and dynamic stretch ranges: `var visParams = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};` 2. Computing Band Math: Use `.normalizedDifference(['B8', 'B4'])` to compute NDVI directly on the cloud across millions of pixels in milliseconds. 3. Exporting Data: Use `Export.image.toDrive()` to export analytical raster products directly to your Google Drive in Cloud-Optimized GeoTIFF format.

āš ļø Common Errors & Troubleshooting

āŒ 'Line 1: ee.ImageCollection is not defined' in browser console

šŸ’” Resolution: Execute code inside the official Earth Engine Code Editor (code.earthengine.google.com), not a generic JavaScript console.

āŒ 'User memory limit exceeded' during spatial reduce

šŸ’” Resolution: Avoid calling '.getInfo()' on massive collections; export the final calculation to Google Drive via 'Export.image.toDrive()'.

šŸ’” Expert Tips & Best Practices

  • Never use client-side JavaScript 'for' loops to process images; always use the functional 'collection.map()' server method.
  • Use 'ee.Reducer.median()' to create cloud-free composite mosaics across multi-temporal image stacks.

🌐 Google Earth Engine JavaScript API Cloud Script

// Define Region of Interest (Point coordinates: New Delhi)
var roi = ee.Geometry.Point([77.2090, 28.6139]).buffer(15000);

// Load Sentinel-2 Level-2A Surface Reflectance Collection
var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
  .filterBounds(roi)
  .filterDate('2023-10-01', '2023-12-31')
  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 15));

// Cloud masking function using the Scene Classification Layer (SCL)
function maskS2clouds(image) {
  var scl = image.select('SCL');
  // Keep vegetation (4), bare soil (5), water (6), unclassified (7)
  var mask = scl.eq(4).or(scl.eq(5)).or(scl.eq(6));
  return image.updateMask(mask).divide(10000);
}

// Map cloud mask and calculate cloud-free median composite
var composite = s2.map(maskS2clouds).median().clip(roi);

// Calculate NDVI directly on server
var ndvi = composite.normalizedDifference(['B8', 'B4']).rename('NDVI');

// Center map view and add layers
Map.centerObject(roi, 11);
Map.addLayer(composite, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.3}, 'True Color RGB');
Map.addLayer(ndvi, {min: 0, max: 0.8, palette: ['blue', 'white', 'green']}, 'NDVI Canopy');

šŸ”— Related Tutorials & Practical Workflows