Google Earth Engine Tutorial: Create Historical Timelapse Images
Credit: Youtube Channel “Terra Spatial, Tutorial on using Google Earth Engine to generate timelapse imagery showing landscape changes over time.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine Tutorial: Create Historical Timelapse Images
Introduction
Google Earth Engine (GEE) is a powerful cloud-based platform that allows researchers and developers to analyze and visualize large-scale geospatial datasets. One of its most impressive capabilities is creating historical timelapse images that show how landscapes have changed over time. This tutorial will guide you through the process of creating stunning timelapse animations using satellite imagery available in Google Earth Engine.
Prerequisites
- A Google Earth Engine account (sign up at earthengine.google.com)
- Basic knowledge of JavaScript (GEE’s scripting language)
- Familiarity with GEE Code Editor
Getting Started
First, navigate to the Google Earth Engine Code Editor at code.earthengine.google.com. This is where we’ll write our script to create timelapse images.
Step-by-Step Tutorial
1. Define Your Area of Interest
// Define a point of interest
var point = ee.Geometry.Point([-122.0841, 37.4219]); // Stanford University coordinates
var areaOfInterest = point.buffer(5000); // Buffer by 5km radius
// Alternative: Define a polygon
var polygon = ee.Geometry.Polygon(
[[[-122.5, 37.8], [-122.5, 37.6], [-122.3, 37.6], [-122.3, 37.8]]]);
2. Select Satellite Imagery Dataset
For timelapse creation, we typically use Landsat imagery due to its long temporal coverage and consistent quality:
// Load Landsat 8 collection
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
.filterBounds(areaOfInterest)
.filterDate('2013-01-01', '2023-12-31')
.filter(ee.Filter.lt('CLOUD_COVER', 20));
3. Create Visualization Parameters
// Define visualization parameters for RGB composite
var visParams = {
bands: ['SR_B4', 'SR_B3', 'SR_B2'], // NIR, Red, Green
min: 0,
max: 0.3,
gamma: [1.3, 1.3, 1.3]
};
4. Generate Timelapse Function
// Function to create timelapse frames
var createTimelapse = function(collection, visParams, region, frames) {
var videoArgs = {
dimensions: 768,
region: region,
framesPerSecond: frames,
crs: 'EPSG:3857',
min: visParams.min,
max: visParams.max,
bands: visParams.bands
};
return collection.getVideoThumbURL(videoArgs);
};
// Generate timelapse URL
var timelapseURL = createTimelapse(collection, visParams, areaOfInterest, 10);
print('Timelapse URL:', timelapseURL);
5. Alternative: Create Yearly Composites
For cleaner images, you might want to create yearly composites:
// Function to create yearly median composite
var createYearlyComposite = function(year) {
var startDate = ee.Date.fromYMD(year, 1, 1);
var endDate = startDate.advance(1, 'year');
return ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
.filterBounds(areaOfInterest)
.filterDate(startDate, endDate)
.filter(ee.Filter.lt('CLOUD_COVER', 20))
.median()
.set('system:time_start', startDate.millis())
.set('year', year);
};
// Create image collection for multiple years
var years = ee.List.sequence(2013, 2023);
var yearlyComposites = ee.ImageCollection(years.map(createYearlyComposite));
6. Display Results
// Add results to the map
Map.centerObject(areaOfInterest, 10);
Map.addLayer(yearlyComposites.first(), visParams, 'Yearly Composite');
Advanced Techniques
Cloud Masking
// Function to mask clouds in Landsat 8 imagery
var maskClouds = function(image) {
var qa = image.select('QA_PIXEL');
var cloudMask = qa.bitwiseAnd(parseInt('11111', 2)).eq(0);
return image.updateMask(cloudMask);
};
// Apply cloud masking to collection
var cloudFreeCollection = collection.map(maskClouds);
NDVI Timelapse
Create vegetation change timelapse using NDVI:
// Function to calculate NDVI
var calculateNDVI = function(image) {
return image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
};
// Apply to collection
var ndviCollection = collection.map(calculateNDVI);
// NDVI visualization parameters
var ndviVis = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
Exporting Timelapse
To export your timelapse video:
- Run your script to generate the video URL
- Click the “Run” button in the Code Editor
- Wait for the URL to appear in the Console
- Click the URL to open the video in a new tab
- Right-click and save the video to your computer
Performance Tips
- Keep your area of interest small for faster processing
- Limit the time range to reduce processing time
- Use cloud-free filters to ensure consistent image quality
- Test with lower resolution first before exporting high-quality videos
Frequently Asked Questions
What is the maximum duration I can create for a timelapse?
Google Earth Engine allows you to create timelapse animations for any time period, but video export limitations apply. For practical purposes, timelapses typically cover periods from a few years to several decades. For longer periods, consider creating yearly composites rather than using every available image.
Can I create timelapses for any location on Earth?
Yes, you can create timelapses for any location where satellite imagery is available. However, imagery availability varies by location and time period. Landsat coverage is global, but some regions may have more data gaps than others.
How do I improve the quality of my timelapse images?
To improve quality, use cloud masking functions, create temporal composites (like monthly or yearly medians), apply appropriate visualization parameters, and ensure consistent processing across all time periods. Also, consider the seasonal patterns in your study area when selecting time ranges.
What are the export limitations in Google Earth Engine?
Free users have limitations on export size and processing time. Large area, high-resolution, or long-duration timelapses may hit these limits. Consider upgrading to Earth Engine’s paid plans or optimizing your processing parameters for better results within limitations.
Can I use Sentinel-2 data instead of Landsat?
Absolutely! Sentinel-2 offers higher spatial resolution (10m vs 30m) and more frequent revisit times. Replace the Landsat collection ID with ‘COPERNICUS/S2_SR’ and adjust the band names accordingly (e.g., ‘B4’, ‘B3’, ‘B2’ for RGB).
How can I reduce cloud cover in my timelapse?
Use cloud masking algorithms, filter collections by cloud cover percentage, select seasonal composites, or use multi-temporal compositing methods. The ‘qualityMosaic’ function can help select pixels with the highest quality across the time series.
Conclusion
Creating historical timelapse images with Google Earth Engine opens up new possibilities for visualizing landscape changes over time. Whether you’re studying urban development, deforestation, agricultural changes, or natural disasters, timelapse animations provide a compelling way to communicate temporal changes in land cover and use.
Remember to experiment with different visualization parameters, time ranges, and processing techniques to achieve the best results for your specific application. The key to successful timelapse creation lies in balancing data quality, processing efficiency, and visual appeal.