Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Stay organized with collections
Save and categorize content based on your preferences.
Aggregates over a given property of the objects in a collection, calculating the sum, min, max, mean, sample standard deviation, sample variance, total standard deviation and total variance of the selected property.
Usage
Returns
ImageCollection.aggregate_stats(property)
Dictionary
Argument
Type
Details
this: collection
FeatureCollection
The collection to aggregate over.
property
String
The property to use from each element of the collection.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eCalculates summary statistics (sum, min, max, mean, standard deviation, and variance) for a specified property across all images within an ImageCollection.\u003c/p\u003e\n"],["\u003cp\u003eAccepts an ImageCollection and a property name as input and returns a dictionary containing the calculated statistics.\u003c/p\u003e\n"],["\u003cp\u003eOffers separate functions for calculating individual statistics (e.g., \u003ccode\u003eaggregate_mean\u003c/code\u003e, \u003ccode\u003eaggregate_min\u003c/code\u003e) or a comprehensive summary using \u003ccode\u003eaggregate_stats\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eHandles both numerical and string properties, with min/max for strings based on alphanumeric order.\u003c/p\u003e\n"],["\u003cp\u003eCan be used with Earth Engine client libraries in JavaScript and Python.\u003c/p\u003e\n"]]],[],null,["# ee.ImageCollection.aggregate_stats\n\nAggregates over a given property of the objects in a collection, calculating the sum, min, max, mean, sample standard deviation, sample variance, total standard deviation and total variance of the selected property.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------|------------|\n| ImageCollection.aggregate_stats`(property)` | Dictionary |\n\n| Argument | Type | Details |\n|--------------------|-------------------|----------------------------------------------------------|\n| this: `collection` | FeatureCollection | The collection to aggregate over. |\n| `property` | String | The property to use from each element of the collection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Lansat 8 TOA image collection for a specific year and location.\nvar col = ee.ImageCollection(\"LANDSAT/LC08/C02/T1_TOA\")\n .filterBounds(ee.Geometry.Point([-122.073, 37.188]))\n .filterDate('2018', '2019');\n\n// An image property of interest, percent cloud cover in this case.\nvar prop = 'CLOUD_COVER';\n\n// Use ee.ImageCollection.aggregate_* functions to fetch information about\n// values of a selected property across all images in the collection. For\n// example, produce a list of all values, get counts, and calculate statistics.\nprint('List of property values', col.aggregate_array(prop));\nprint('Count of property values', col.aggregate_count(prop));\nprint('Count of distinct property values', col.aggregate_count_distinct(prop));\nprint('First collection element property value', col.aggregate_first(prop));\nprint('Histogram of property values', col.aggregate_histogram(prop));\nprint('Min of property values', col.aggregate_min(prop));\nprint('Max of property values', col.aggregate_max(prop));\n\n// The following methods are applicable to numerical properties only.\nprint('Mean of property values', col.aggregate_mean(prop));\nprint('Sum of property values', col.aggregate_sum(prop));\nprint('Product of property values', col.aggregate_product(prop));\nprint('Std dev (sample) of property values', col.aggregate_sample_sd(prop));\nprint('Variance (sample) of property values', col.aggregate_sample_var(prop));\nprint('Std dev (total) of property values', col.aggregate_total_sd(prop));\nprint('Variance (total) of property values', col.aggregate_total_var(prop));\nprint('Summary stats of property values', col.aggregate_stats(prop));\n\n// Note that if the property is formatted as a string, min and max will\n// respectively return the first and last values according to alphanumeric\n// order of the property values.\nvar propString = 'LANDSAT_SCENE_ID';\nprint('List of property values (string)', col.aggregate_array(propString));\nprint('Min of property values (string)', col.aggregate_min(propString));\nprint('Max of property values (string)', col.aggregate_max(propString));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nfrom pprint import pprint\n\n# A Lansat 8 TOA image collection for a specific year and location.\ncol = ee.ImageCollection(\"LANDSAT/LC08/C02/T1_TOA\").filterBounds(\n ee.Geometry.Point([-122.073, 37.188])).filterDate('2018', '2019')\n\n# An image property of interest, percent cloud cover in this case.\nprop = 'CLOUD_COVER'\n\n# Use ee.ImageCollection.aggregate_* functions to fetch information about\n# values of a selected property across all images in the collection. For\n# example, produce a list of all values, get counts, and calculate statistics.\nprint('List of property values:', col.aggregate_array(prop).getInfo())\nprint('Count of property values:', col.aggregate_count(prop).getInfo())\nprint('Count of distinct property values:',\n col.aggregate_count_distinct(prop).getInfo())\nprint('First collection element property value:',\n col.aggregate_first(prop).getInfo())\nprint('Histogram of property values:')\npprint(col.aggregate_histogram(prop).getInfo())\nprint('Min of property values:', col.aggregate_min(prop).getInfo())\nprint('Max of property values:', col.aggregate_max(prop).getInfo())\n\n# The following methods are applicable to numerical properties only.\nprint('Mean of property values:', col.aggregate_mean(prop).getInfo())\nprint('Sum of property values:', col.aggregate_sum(prop).getInfo())\nprint('Product of property values:', col.aggregate_product(prop).getInfo())\nprint('Std dev (sample) of property values:',\n col.aggregate_sample_sd(prop).getInfo())\nprint('Variance (sample) of property values:',\n col.aggregate_sample_var(prop).getInfo())\nprint('Std dev (total) of property values:',\n col.aggregate_total_sd(prop).getInfo())\nprint('Variance (total) of property values:',\n col.aggregate_total_var(prop).getInfo())\nprint('Summary stats of property values:')\npprint(col.aggregate_stats(prop).getInfo())\n\n# Note that if the property is formatted as a string, min and max will\n# respectively return the first and last values according to alphanumeric\n# order of the property values.\nprop_string = 'LANDSAT_SCENE_ID'\nprint('List of property values (string):',\n col.aggregate_array(prop_string).getInfo())\nprint('Min of property values (string):',\n col.aggregate_min(prop_string).getInfo())\nprint('Max of property values (string):',\n col.aggregate_max(prop_string).getInfo())\n```"]]