Temporally Filter Image Collection

Select images for your specific period of interest

This introductory training is part of the official training materials prepared by the United States Department of Agriculture.

The Code Editor offers access to the full power of Earth Engine; however, a basic understanding of the fundamentals of coding and JavaScript is required. In this exercise, you will continue to learn about JavaScript syntax and some new Earth Engine spatial data concepts. You will build what you learned in exercise two about image objects; however you will now turn your focus to working with collections of images, or stacks of similar image objects. In this exercise, you will focus on basic concepts and methods associated with image collections in Earth Engine. This is an introduction to get users writing some simple JavaScript scripts.

Temporally Filter Image Collection

A. Create a date-limited image collection

1. Next add a statement that filters your image collection by a length of time, using the filterDate() method (see example script below). filterDate() allows us to specify a start and end date as parameters to reduce the size of our collection to meet our project goals. The new lines add a filter to the data collection, L8_StudyArea, based on the date the images were taken.

2. Next, let’s add a count and print statement to see how many images are in our new image collection.

3. I’ve included the full script below. Modify your script to match and Run the code.

// Get a collection.
var L8_collection = ee.ImageCollection('LANDSAT/LC8_L1T_TOA');

// Filter to scenes that intersect your boundary
var L8_StudyArea = L8_collection.filterBounds(StudyArea);

// Filter to scenes for a given time period
var L8_SA_2015 = L8_StudyArea.filterDate('2015-01-01', '2015-12-31');

Map.addLayer(L8_SA_2015,
{ min:0.05, max: 0.8, bands: 'B6, B5, B4' });
Map.centerObject(StudyArea, 7);

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

// Get the number of images.
var count15 = L8_SA_2015.size();
print('Count of L8_SA-2015: ', count15);

4. (Optional) Below are some additional methods you can use to explore your image collection. These are taken from the following page in the user documentation: https://developers.google.com/earth-engine/ic_info

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

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

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

4 thoughts on “Temporally Filter Image Collection”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s