公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.ImageCollection.aggregate_sample_var
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
针对集合中对象的指定属性进行汇总,计算所选属性值的样本方差。
用法 | 返回 |
---|
ImageCollection.aggregate_sample_var(property) | 数字 |
参数 | 类型 | 详细信息 |
---|
此:collection | FeatureCollection | 要汇总的集合。 |
property | 字符串 | 要从集合的每个元素中使用的属性。 |
示例
代码编辑器 (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));
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
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())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eaggregate_sample_var\u003c/code\u003e calculates the sample variance of a specified property across an ImageCollection.\u003c/p\u003e\n"],["\u003cp\u003eIt operates on a given property within each image of the collection.\u003c/p\u003e\n"],["\u003cp\u003eThe result is a single number representing the sample variance of the chosen property's values.\u003c/p\u003e\n"],["\u003cp\u003eThis function is part of a suite of aggregation methods that can provide various statistics about ImageCollection properties.\u003c/p\u003e\n"]]],["The provided code demonstrates how to use `aggregate_*` functions on an `ImageCollection` to derive information about a specified property. Actions include listing all property values, getting counts, finding the first element's property value, creating histograms, and calculating statistical measures like min, max, mean, sum, product, standard deviation, and variance. These methods work on numeric properties, while string property methods are restricted to min and max (alphanumeric order).\n"],null,["# ee.ImageCollection.aggregate_sample_var\n\nAggregates over a given property of the objects in a collection, calculating the sample variance of the values of the selected property.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------------------|---------|\n| ImageCollection.aggregate_sample_var`(property)` | Number |\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# 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```"]]