🌐
Introduction to Google Earth Engine
  • Google Earth Engine
  • What is Google Earth Engine?
  • How to Use Google Earth Engine
    • GEE Interface Platforms
    • Data Catalog
    • Using the Code Editor
      • Adding Data
      • Objects and Methods
        • ee.Image
        • ee.ImageCollection
        • ee.Geometry
        • ee.Feature and FeatureCollection
      • Image Classification
      • Data Visualisation
  • Useful Resources
Powered by GitBook
On this page
  • Sentinel ImageCollection
  • Filtering an Image
  • Sorting an ImageCollection
  • Reducing Images

Was this helpful?

  1. How to Use Google Earth Engine
  2. Using the Code Editor
  3. Objects and Methods

ee.ImageCollection

Previousee.ImageNextee.Geometry

Last updated 3 years ago

Was this helpful?

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.

Screenshot of GEE Code Editor, showing the Console tab. In this case, filtering the ImageCollection has resulted in the selection of 11 Images.
Screenshot of GEE Code Editor, showing the Console tab. In this case, selecting the median values of the filtered ImageCollection has resulted in the selection of 1 Image.
Screenshot of the Sentinel Collection in the GEE data catalog
landing page, GEE Data Catalog
https://developers.google.com/earth-engine/datasets/catalog/sentinel
S2a MSI ImageCollection