ee.ImageCollection.aggregate_stats
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tổng hợp trên một thuộc tính nhất định của các đối tượng trong một tập hợp, tính tổng, giá trị tối thiểu, giá trị tối đa, giá trị trung bình, độ lệch chuẩn của mẫu, phương sai của mẫu, tổng độ lệch chuẩn và tổng phương sai của thuộc tính đã chọn.
Cách sử dụng | Giá trị trả về |
---|
ImageCollection.aggregate_stats(property) | Từ điển |
Đối số | Loại | Thông tin chi tiết |
---|
this: collection | FeatureCollection | Bộ sưu tập cần tổng hợp. |
property | Chuỗi | Thuộc tính cần sử dụng từ mỗi phần tử của bộ sưu tập. |
Ví dụ
Trình soạn thảo mã (JavaScript)
// A Lansat 8 TOA image collection for a specific year and location.
var col = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA")
.filterBounds(ee.Geometry.Point([-122.073, 37.188]))
.filterDate('2018', '2019');
// An image property of interest, percent cloud cover in this case.
var prop = 'CLOUD_COVER';
// Use ee.ImageCollection.aggregate_* functions to fetch information about
// values of a selected property across all images in the collection. For
// example, produce a list of all values, get counts, and calculate statistics.
print('List of property values', col.aggregate_array(prop));
print('Count of property values', col.aggregate_count(prop));
print('Count of distinct property values', col.aggregate_count_distinct(prop));
print('First collection element property value', col.aggregate_first(prop));
print('Histogram of property values', col.aggregate_histogram(prop));
print('Min of property values', col.aggregate_min(prop));
print('Max of property values', col.aggregate_max(prop));
// The following methods are applicable to numerical properties only.
print('Mean of property values', col.aggregate_mean(prop));
print('Sum of property values', col.aggregate_sum(prop));
print('Product of property values', col.aggregate_product(prop));
print('Std dev (sample) of property values', col.aggregate_sample_sd(prop));
print('Variance (sample) of property values', col.aggregate_sample_var(prop));
print('Std dev (total) of property values', col.aggregate_total_sd(prop));
print('Variance (total) of property values', col.aggregate_total_var(prop));
print('Summary stats of property values', col.aggregate_stats(prop));
// Note that if the property is formatted as a string, min and max will
// respectively return the first and last values according to alphanumeric
// order of the property values.
var propString = 'LANDSAT_SCENE_ID';
print('List of property values (string)', col.aggregate_array(propString));
print('Min of property values (string)', col.aggregate_min(propString));
print('Max of property values (string)', col.aggregate_max(propString));
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap
cho quá trình phát triển tương tác.
import ee
import geemap.core as geemap
Colab (Python)
from pprint import pprint
# A Lansat 8 TOA image collection for a specific year and location.
col = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA").filterBounds(
ee.Geometry.Point([-122.073, 37.188])).filterDate('2018', '2019')
# An image property of interest, percent cloud cover in this case.
prop = 'CLOUD_COVER'
# Use ee.ImageCollection.aggregate_* functions to fetch information about
# values of a selected property across all images in the collection. For
# example, produce a list of all values, get counts, and calculate statistics.
print('List of property values:', col.aggregate_array(prop).getInfo())
print('Count of property values:', col.aggregate_count(prop).getInfo())
print('Count of distinct property values:',
col.aggregate_count_distinct(prop).getInfo())
print('First collection element property value:',
col.aggregate_first(prop).getInfo())
print('Histogram of property values:')
pprint(col.aggregate_histogram(prop).getInfo())
print('Min of property values:', col.aggregate_min(prop).getInfo())
print('Max of property values:', col.aggregate_max(prop).getInfo())
# The following methods are applicable to numerical properties only.
print('Mean of property values:', col.aggregate_mean(prop).getInfo())
print('Sum of property values:', col.aggregate_sum(prop).getInfo())
print('Product of property values:', col.aggregate_product(prop).getInfo())
print('Std dev (sample) of property values:',
col.aggregate_sample_sd(prop).getInfo())
print('Variance (sample) of property values:',
col.aggregate_sample_var(prop).getInfo())
print('Std dev (total) of property values:',
col.aggregate_total_sd(prop).getInfo())
print('Variance (total) of property values:',
col.aggregate_total_var(prop).getInfo())
print('Summary stats of property values:')
pprint(col.aggregate_stats(prop).getInfo())
# Note that if the property is formatted as a string, min and max will
# respectively return the first and last values according to alphanumeric
# order of the property values.
prop_string = 'LANDSAT_SCENE_ID'
print('List of property values (string):',
col.aggregate_array(prop_string).getInfo())
print('Min of property values (string):',
col.aggregate_min(prop_string).getInfo())
print('Max of property values (string):',
col.aggregate_max(prop_string).getInfo())
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 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```"]]