ee.ImageCollection

Adding an Image on it's own is useful, but sometimes it's easier to search through a collection of images and filter according to their properties.

The Data Catalog supplies Images often as part of an ImageCollection, which is a stack or sequence of Images.

Sentinel ImageCollection

Here, we're going to look through the Sentinel Collections, made available by the European Commission and European Space Agency's Copernicus Program. It contains vast amounts of data which can be explored in the GEE Data Catalog:

Adding a Collection is straightforward - Earth Engine supplies a snippet that can be copied and used in Code Editor:

Filtering an Image

You can filter an ImageCollection by dataset properties, such as dates, spatial extent, quality etc.

For the polar regions, it is useful to filter by date to remove times without sunlight, area of interest, or cloud cover.

You can also chain filters so you apply them all at once:

var s2_filter = ee.ImageCollection('COPERNICUS/S2_SR')  
                .filterDate('2022-01-01', '2022-05-01')  
                .filterBounds(ee.Geometry.Point(-68.124, -67.5679))  
                .filter('CLOUDY_PIXEL_PERCENTAGE < 50');

Sorting an ImageCollection

Sometimes it is useful to sort a collection by properties such as by observation time, cloud cover etc.

ee.ImageCollection('').sort('property')

This can look like:

var s2_sort_obs = ee.ImageCollection('COPERNICUS/S2_SR')
  .filterBounds(ee.Geometry.Point(-68.124, -67.5679))
  .filterDate('2022-11-01', '2022-03-01')  
  // Sort by observation time:
  .sort('system:time_start');

Or by cloudiness:

var s2_sort_clouds = ee.ImageCollection('COPERNICUS/S2_SR')
  .filterBounds(ee.Geometry.Point(-68.124, -67.5679))
  .filterDate('2022-01-01', '2022-05-01')
  // Sort by Cloud parameter: 
  .sort('CLOUDY_PIXEL_PERCENTAGE');

Each ImageCollection has different parameters, according to the instrument that captured the data. You can read more about each ImageCollection in the Data Catalog

Reducing Images

Filtering an ImageCollection often results with multiple images.

This can be reviewed in the CodeEditor by printing the results in the Console:

var s2_filter = ee.ImageCollection('COPERNICUS/S2_SR')  
                .filterDate('2021-09-01', '2022-03-01')  
                .filterBounds(ee.Geometry.Point(-68.124, -67.5679))  
                .filter('CLOUDY_PIXEL_PERCENTAGE < 50')
                
var s2_filter_rgb = s2_filter.select(['B4', 'B3', 'B2']);

print('s2_filter_rgb', s2_filter_rgb)

In the Console we can see that this filter has resulted in 11 images:

While this is useful, it would be easier if we only had one image to manage. We can do this by reducing the ImageCollection by value. In this case, we can look for the Median values across each pixel.

ee.ImageCollection.median

This can look like:

var s2_filter = ee.ImageCollection('COPERNICUS/S2_SR')  
                .filterDate('2021-09-01', '2022-03-01')  
                .filterBounds(ee.Geometry.Point(-68.124, -67.5679))  
                .filter('CLOUDY_PIXEL_PERCENTAGE < 50')


var s2_filter_rgb = s2_filter.select(['B4', 'B3', 'B2'])

var composite = s2_filter_rgb.median();

print('median composite:', composite)

And now the Console shows that the result is one single Image, composed of the 3 bands:

Compared to the Filtered ImageCollection output, the Median Composite has less cloud-covered pixels.

Last updated