Filtering an ImageCollection

As illustrated in the Get Started section and the ImageCollection Information section, Earth Engine provides a variety of convenience methods for filtering image collections. Specifically, many common use cases are handled by imageCollection.filterDate(), and imageCollection.filterBounds(). For general purpose filtering, use imageCollection.filter() with an ee.Filter as an argument. The following example demonstrates both convenience methods and filter() to identify and remove images with bad registration from an ImageCollection:

Code Editor (JavaScript)

// Load Landsat 5 data, filter by date and bounds.
var collection = ee.ImageCollection('LANDSAT/LT05/C01/T2')
  .filterDate('1987-01-01', '1990-05-01')
  .filterBounds(ee.Geometry.Point(25.8544, -18.08874));

// Also filter the collection by the IMAGE_QUALITY property.
var filtered = collection
  .filterMetadata('IMAGE_QUALITY', 'equals', 9);

// Create two composites to check the effect of filtering by IMAGE_QUALITY.
var badComposite = ee.Algorithms.Landsat.simpleComposite(collection, 75, 3);
var goodComposite = ee.Algorithms.Landsat.simpleComposite(filtered, 75, 3);

// Display the composites.
Map.setCenter(25.8544, -18.08874, 13);
             {bands: ['B3', 'B2', 'B1'], gain: 3.5},
             'bad composite');
             {bands: ['B3', 'B2', 'B1'], gain: 3.5},
             'good composite');