Tutorial: Getting Started with Google Earth Engine

Listen to this article

What is Google Earth Engine?

Google Earth Engine is a platform that combines a vast catalog of satellite imagery and geospatial datasets with planetary-scale computing power. It’s widely used for applications like deforestation monitoring, climate analysis, urban planning, and disaster response. GEE’s JavaScript API allows users to write scripts in a web-based code editor, making geospatial analysis accessible without needing to download massive datasets.

Prerequisites

  • A Google account (Gmail or Google Workspace).
  • Basic understanding of JavaScript (helpful but not mandatory—GEE’s syntax is beginner-friendly).
  • Interest in geospatial data or mapping.

Step 1: Sign Up for Google Earth Engine

  1. Visit the GEE Website
    Go to earthengine.google.com. Click the “Sign Up” button.
  2. Request Access
  • You’ll be prompted to log in with your Google account.
  • Fill out the form with your name, email, and a brief description of why you want to use GEE (e.g., “learning geospatial analysis” or “researching deforestation”).
  • Submit the request. Approval typically takes a few hours to a couple of days.
  1. Access Granted
    Once approved, you’ll receive an email with a link to the GEE Code Editor. Bookmark it: code.earthengine.google.com.

Step 2: Explore the GEE Code Editor

The Code Editor is your workspace. When you first log in, you’ll see:

  • Left Panel (Scripts/Assets): For saving scripts and managing uploaded data.
  • Center Panel (Editor): Where you write JavaScript code.
  • Right Panel (Inspector/Console/Map):
  • Inspector: Click on the map to see data values.
  • Console: View outputs or errors.
  • Map: Interactive map to visualize results.
  • Top Bar: Buttons for running scripts, saving, and accessing documentation.

Take a moment to familiarize yourself with this layout—it’s intuitive once you start using it.


Step 3: Write Your First Script

Let’s create a simple script to display a satellite image on the map.

  1. Clear the Editor
    If there’s default code, delete it by selecting all (Ctrl+A or Cmd+A) and pressing Delete.
  2. Add a Satellite Image
    Copy and paste this code into the editor:
   // Load a Landsat 8 image
   var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20230615');

   // Define visualization parameters
   var visParams = {
     bands: ['SR_B4', 'SR_B3', 'SR_B2'], // Red, Green, Blue bands
     min: 0,
     max: 30000
   };

   // Center the map on the image
   Map.setCenter(-122.34, 37.73, 10); // Longitude, Latitude, Zoom level

   // Add the image to the map
   Map.addLayer(image, visParams, 'Landsat 8 Image');
  1. Run the Script
    Click the “Run” button in the top bar. After a moment, a Landsat 8 image of San Francisco from June 15, 2023, will appear on the map.
  2. Understand the Code
  • ee.Image: Loads a specific image from GEE’s catalog (here, a Landsat 8 scene).
  • visParams: Sets how the image is displayed (bands and value range).
  • Map.setCenter: Centers the map view (coordinates are for San Francisco).
  • Map.addLayer: Adds the image to the interactive map.

Step 4: Work with Image Collections

Individual images are useful, but GEE shines with Image Collections—time series of images for analysis.

Example: Calculate NDVI (Vegetation Index)

The Normalized Difference Vegetation Index (NDVI) measures plant health. Here’s how to compute it over a region:

  1. Define a Region of Interest (ROI)
    Add this code to draw a rectangle over an area (e.g., central California):
   var roi = ee.Geometry.Rectangle([-121.0, 36.0, -119.0, 38.0]);
  1. Load an Image Collection
    Use Landsat 8 data for a year:
   var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
     .filterBounds(roi)
     .filterDate('2023-01-01', '2023-12-31');
  1. Calculate NDVI
    Add a function to compute NDVI for each image:
   var addNDVI = function(image) {
     var ndvi = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
     return image.addBands(ndvi);
   };

   var collectionWithNDVI = collection.map(addNDVI);
  1. Visualize the Result
    Take the median NDVI and display it:
   var medianNDVI = collectionWithNDVI.select('NDVI').median();
   var ndviVis = {min: -1, max: 1, palette: ['red', 'white', 'green']};

   Map.setCenter(-120.0, 37.0, 8);
   Map.addLayer(medianNDVI, ndviVis, 'Median NDVI 2023');
  1. Run and Explore
    Hit “Run.” You’ll see a map where green areas indicate healthy vegetation, and red/white areas show sparse or no vegetation.

Step 5: Export Data

GEE lets you export results to Google Drive for further analysis.

  1. Export an Image
    Add this to export the NDVI map:
   Export.image.toDrive({
     image: medianNDVI,
     description: 'Median_NDVI_2023',
     scale: 30, // Resolution in meters
     region: roi,
     maxPixels: 1e9
   });
  1. Run and Check
    Click “Run,” then go to the “Tasks” tab (right panel). Click “Run” next to the export task. Once processed, the file will appear in your Google Drive.

Step 6: Advanced Features

Now that you’ve got the basics, try these:

  • Time Series Analysis: Use .reduce() to summarize data over time (e.g., average rainfall).
  • Machine Learning: Integrate GEE’s classifiers (e.g., Random Forest) for land cover mapping.
  • Custom Data: Upload your own shapefiles or CSV files via the “Assets” tab.

Example: Chart NDVI Over Time

Add this to plot NDVI trends:

var chart = ui.Chart.image.series({
  imageCollection: collectionWithNDVI.select('NDVI'),
  region: roi,
  reducer: ee.Reducer.mean(),
  scale: 30
}).setOptions({title: 'NDVI Over Time in 2023'});
print(chart);

Run it, and a graph will appear in the Console.


Tips for Success

  • Documentation: Use the “Docs” tab in the Code Editor for function references.
  • Community: Explore the GEE Developers Forum for help.
  • Debugging: Check the Console for error messages if something fails.
  • Experiment: GEE has datasets like MODIS, Sentinel, and weather data—play around!

Sample Project Ideas

  1. Deforestation Monitoring: Compare forest cover between two years using Landsat data.
  2. Urban Growth: Map city expansion with nighttime lights data.
  3. Flood Analysis: Overlay precipitation data with elevation to identify flood-prone areas.

Conclusion

Google Earth Engine is a game-changer for geospatial analysis, offering tools that were once the domain of supercomputers. This tutorial introduced you to loading data, visualizing it, performing calculations, and exporting results. With practice, you can tackle real-world problems like climate change or resource management—all from your browser.

Ready to dive deeper? Open the Code Editor, tweak these scripts, and explore GEE’s vast catalog. The Earth is your dataset—start mapping it!

Leave a Reply

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