Skip to content

ImageCollection Information and Metadata

Image Collection metadata and information

As with Images, there are a variety of ways to get information about an ImageCollection. The collection can be printed directly to the console, but the console printout is limited to 5000 elements. Collections larger than 5000 images will need to be filtered before printing. Printing a large collection will be correspondingly slower. The following example shows various ways of getting information about image collections programmatically:

# Import earthengine API
import ee
import pprint

# Initialise
ee.Initialize()

# Configure the pretty printing output & initialize earthengine.
pp = pprint.PrettyPrinter(depth=4)

# Load a Landsat 8 ImageCollection for a single path-row.
collection = (ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filter(ee.Filter.eq('WRS_PATH', 44))
    .filter(ee.Filter.eq('WRS_ROW', 34))
    .filterDate('2014-03-01', '2014-08-01'))
#pp.pprint('Collection: '+str(collection.getInfo())+'\n')

# Get the number of images.
count = collection.size()
print('Count: ', str(count.getInfo())+'\n')

# Get the date range of images in the collection.
range = collection.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date range: ', str(ee.Date(range.get('min')).getInfo()), str(ee.Date(range.get('max')).getInfo())+'\n')

# Get statistics for a property of the images in the collection.
sunStats = collection.aggregate_stats('SUN_ELEVATION')
pp.pprint('Sun elevation statistics: '+str(sunStats.getInfo())+'\n')

# Sort by a cloud cover property, get the least cloudy image.
image = ee.Image(collection.sort('CLOUD_COVER').first())
print('Least cloudy image: ', str(image.getInfo())+'\n')

# Limit the collection to the 10 most recent images.
recent = collection.sort('system:time_start', False).limit(10)
#pp.pprint('Recent images: '+str(recent.getInfo())+'\n')

# Get size of collection in bytes
print('Total size of Collection with 10 most recent images : '+str((recent.reduceColumns(ee.Reducer.sum(), ['system:asset_size']).getInfo()['sum'])))

  1. Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 4.0 Attribution License. Code samples are licensed under the Apache 2.0 License 

  2. Last updated July 10, 2019.