Lab Lecture: Fall 2023 Recording
Introduction: The Landsat Program
The Landsat program from NASA and the United States Geological Survey (USGS) has launched a sequence of Earth observation satellites named Landsat 1, 2, etc. Landsats have been returning images since 1972, making that collection of images the longest continuous satellite-based observation of the Earth's surface.
The Landsat program has revolutionized remote sensing and land observation. The program was initially developed to improve the understanding of the Earth's terrestrial and aquatic ecosystems, but its use quickly grew to encompass a wide range of fields, such as natural resource exploration, disaster preparedness, urban planning, and agricultural monitoring.
The Landsat satellites are designed to capture detailed images of the Earth's surface on a regular basis with a spatial resolution of 30 meters per pixel in visible and near-infrared light bands, with additional infrared and thermal band capabilities. Additionally, Landsat data is freely available to the public, making it a valuable tool for both professional and amateur users.
Lab Instructions
-
Viewing an Image Collection
Open up Google Earth Engine Code: https://code.earthengine.google.com/
Copy and paste the following code into the center panel and click Run:
///// // View an Image Collection ///// // Import the Landsat 8 Raw Collection. var landsat8 = ee.ImageCollection('LANDSAT/LC08/C02/T1'); // Print the size of the Landsat 8 dataset. print('The size of the Landsat 8 image collection is:', landsat8.size()); // Try to print the image collection. // WARNING! Running the print code immediately below produces an error because // the Console cannot print more than 5000 elements. print(landsat8); // Add the Landsat 8 dataset to the map as a mosaic. Map.addLayer(landsat8, { bands: ['B4', 'B3', 'B2'], min: 5000, max: 15000 }, 'Landsat 8 Image Collection');While the enormous image catalog is accessed, it could take a couple of minutes to see the result. You may note individual "scenes" being drawn, which equate to the way that the Landsat program partitions Earth into "paths" and "rows."
Screenshot of Landsat being drawn on Google Earth Engine Note about Rows and Paths: Images from Landsat are placed in a grid pattern. A row is a sequence of images taken at the same latitude, while a path is a series of images taken at the same longitude. Paths are numbered from west to east starting at the 180-degree longitude line. Rows are numbered from south to north starting at the equator.
Notice the high amount of cloud cover and the "layered" look. This is because Earth Engine is drawing each of the images one on top of the other.
The number of Landsat images in the collection (over 1 million!)
Error from trying to print too many elements -
Comment Out Code
Edit your code to "comment out" the last two code commands using
//at the beginning of each line. This will speed up your code in subsequent sections.
Commented out code -
Filter by Date
Now we will look at finding "the needle in the haystack." The basic approach to GEE is to add an image collection that brings in every image, then to filter the collection until you find the exact image you're interested in.
filterDateallows us to narrow down the date range of the ImageCollection. Copy and paste:///// // Filter an Image Collection ///// // Filter the collection by date. var landsatWinter = landsat8.filterDate('2020-12-01', '2021-03-01'); Map.addLayer(landsatWinter, { bands: ['B4', 'B3', 'B2'], min: 5000, max: 15000 }, 'Winter Landsat 8'); print('The size of the Winter Landsat 8 image collection is:', landsatWinter.size());The result will load much faster because we filtered by date. Notice that before we had over a million images; after filtering, we have thousands.
Results from filtering by date Comment out the Map.addLayer for winter imagery before moving on.
Commented out winter imagery code -
Filter by Location
The filtering tool
filterBoundsis based on a location—for example, a point, polygon, or other geometry. Copy and paste:///// // Filter by location ///// // Create an Earth Engine Point object. var pointFL = ee.Geometry.Point([-82.32, 29.65]); // Filter the collection by location using the point. var landsatFL = landsatWinter.filterBounds(pointFL); Map.addLayer(landsatFL, { bands: ['B4', 'B3', 'B2'], min: 5000, max: 15000 }, 'FL Landsat 8'); // Add the point to the map to see where it is. Map.addLayer(pointFL, {}, 'Point FL'); print('The size of the Gainesville Winter Landsat 8 image collection is: ', landsatFL.size());Note that we add the pointFL to the map with an empty dictionary
{}for the visParams argument—we are not specifying visualization parameters, using defaults instead.Run the code. Now only images that intersect our point have been selected. Note we only have 12 images.
Filtered by location results -
Select First Image
The
firstfunction selects the first image in an ImageCollection. This allows us to place a single image on the screen. Because images are stored in time order, it will select the earliest image.
Filtered to a single image Notice the image is very cloudy. Normally this is a problem for analysis—we prefer images without clouds. Each image in Landsat's collection has a cloud cover rating we can use.
-
Sort by Cloud Cover
The basic approach is to sort the ImageCollection by cloud cover, then add the first image:
// Sort the image collection by cloud cover var landsatSort = landsatFL.sort('CLOUD_COVER'); // Select the first image in the sorted collection. var landsatFirstSort = landsatSort.first(); // Display the first image in the sorted collection. Map.centerObject(landsatFirstSort, 7); Map.addLayer(landsatFirstSort, { bands: ['B4', 'B3', 'B2'], min: 5000, max: 15000 }, 'Sort Landsat 8');Now you have a single Landsat image with no cloud cover, filtered for Gainesville during the winter of 2020-2021!
Cloud-free sorted image result Full code link: GEE Code
Challenge
Challenge Task:
Using the filtering method, create code that displays a single cloud-free image of the Champs De Mars in Paris, France, in the summer of 2022 (June-August). Display the image in both Natural Color and Color Infrared.
Requirements:
- Filter by date (summer 2022)
- Filter by location (Paris coordinates)
- Sort by cloud cover
- Display in two band combinations
- Follow good coding practices with detailed comments
📧 Lab Submission
Submit lab via email.
Subject: Lab 6 - Image Collections - [Your Name]
Include:
- Shareable link to your GEE script
- Screenshots of Paris in both natural color and false color
- Well-commented code explaining your approach