Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.ImageCollection.size

  • Thesize() method returns the number of elements in a collection.

  • Usingsize() on large or complex collections can consume significant time and memory, potentially causing errors.

  • The method is used withImageCollection.size() and returns an Integer.

  • Examples are provided in both JavaScript and Python.

Returns the number of elements in the collection.

UsageReturns
ImageCollection.size()Integer
ArgumentTypeDetails
this:collectionFeatureCollectionThe collection to count.

Examples

Code Editor (JavaScript)

// Note: ee.ImageCollection.size may take a lot of time and memory to run,// since it must generate all of the results in order to count them. Large// collections and/or complex computations can produce memory limitation// errors.// A Landsat 8 TOA image collection (1 year of images at a specific point).varcol=ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(ee.Geometry.Point(-90.70,34.71)).filterDate('2020-01-01','2021-01-01');// Get the number of images in the collection.print('Number of images',col.size());

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

# Note: ee.ImageCollection.size may take a lot of time and memory to run,# since it must generate all of the results in order to count them. Large# collections and/or complex computations can produce memory limitation# errors.# A Landsat 8 TOA image collection (1 year of images at a specific point).col=ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(ee.Geometry.Point(-90.70,34.71)).filterDate('2020-01-01','2021-01-01')# Get the number of images in the collection.display('Number of images',col.size())

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.