Link Search Menu Expand Document

Tutorial 5

Exploring image collections and their metadata

// Specify a location and date range of interest
var point = ee.Geometry.Point(-76.147, 43.046); // Create a point in the City of Syracuse
var start = ee.Date('2014-06-01'); //Define a start date for filter
var end = ee.Date('2014-10-01'); //Define a end date for filter

// Filtering and Sorting an ImageCollection
var filteredCollection = ee.ImageCollection('LANDSAT/LC8_L1T') //import all Landsat 8 scenes
.filterBounds(point) //filter all scenes using point geometry from above (i.e. limit to Syracuse)
.filterDate(start, end) //filter all scenes using the dates defined above
print(filteredCollection);

var first = filteredCollection.first(); //select the first image in the filtered image collection
print(first); //Based on the sort above, the first image here has the lowest cloud cover

// Load a Landsat 8 ImageCollection for a single path-row.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filter(ee.Filter.eq('WRS_PATH', 15)) //Limit images to those in the path/row over Syracuse
.filter(ee.Filter.eq('WRS_ROW', 30)) 
.filterDate('2014-01-01', '2015-01-01'); //filter by a start and end date of interest

print('Collection: ', collection);

// Convert the collection to a list and get the number of images.
var size = collection.toList(100).length();
print('Number of images: ', size);

// Get the number of images.
var count = collection.size();
print('Count: ', count);

// Get statistics for a property of the images in the collection.
var sunStats = collection.aggregate_stats('SUN_ELEVATION');
print('Sun elevation statistics: ', sunStats);

// Sort by a cloud cover property, get the least cloudy image.
var image = ee.Image(collection.sort('CLOUD_COVER').first());
print('Least cloudy image: ', image);

// Limit the collection to the 10 most recent images.
var recent = collection.sort('system:time_start', false).limit(10);
print('Recent images: ', recent);