公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.ImageCollection.getArray
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从功能中提取属性。
用法 | 返回 |
---|
ImageCollection.getArray(property) | 数组 |
参数 | 类型 | 详细信息 |
---|
此:object | 元素 | 要从中提取属性的要素。 |
property | 字符串 | 要提取的属性。 |
示例
代码编辑器 (JavaScript)
// A contrived, empty image collection for simple demonstration.
var col = ee.ImageCollection([]);
print('Collection without properties', col);
// Set collection properties using a dictionary.
col = col.set({
project_name: 'biomass_tracking',
project_id: 3,
plot_ids: ee.Array([7, 11, 20])
});
// Set collection properties using a series of key-value pairs.
col = col.set('project_year', 2018,
'rgb_vis', 'false_color');
print('Collection with properties', col);
// Get a dictionary of collection property keys and values.
print('Property keys and values (ee.Dictionary)', col.toDictionary());
// Get the value of a collection property. To use the result of
// ee.ImageCollection.get in further computation, you need to cast it to the
// appropriate class, for example, ee.Number(result) or ee.String(result).
print('Project ID (ambiguous object)', col.get('project_id'));
// Get the value of a string collection property as an ee.String object.
print('Project name (ee.String)', col.getString('project_name'));
// Get the value of a numeric collection property as an ee.Number object.
print('Project year (ee.Number)', col.getNumber('project_year'));
// Get the value of an ee.Array collection property as an ee.Array object.
print('Plot IDs (ee.Array)', col.getArray('plot_ids'));
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
from pprint import pprint
# A contrived, empty image collection for simple demonstration.
col = ee.ImageCollection([])
print('Collection without properties:')
pprint(col.getInfo())
# Set collection properties using a dictionary.
col = col.set({
'project_name': 'biomass_tracking',
'project_id': 3,
'plot_ids': ee.Array([7, 11, 20])
})
# Set collection properties using a series of key-value pairs.
col = col.set('project_year', 2018,
'rgb_vis', 'false_color')
print('Collection with properties:')
pprint(col.getInfo())
# Get a dictionary of collection property keys and values.
print('Property keys and values (ee.Dictionary):')
pprint(col.toDictionary().getInfo())
# Get the value of a collection property. To use the result of
# ee.ImageCollection.get in further computation, you need to cast it to the
# appropriate class, for example, ee.Number(result) or ee.String(result).
print('Project ID (ambiguous object):', col.get('project_id').getInfo())
# Get the value of a string collection property as an ee.String object.
print('Project name (ee.String):', col.getString('project_name').getInfo())
# Get the value of a numeric collection property as an ee.Number object.
print('Project year (ee.Number):', col.getNumber('project_year').getInfo())
# Get the value of an ee.Array collection property as an ee.Array object.
print('Plot IDs (ee.Array):', col.getArray('plot_ids').getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eImageCollection.get()\u003c/code\u003e extracts a property value from an \u003ccode\u003eImageCollection\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve the property value by specifying the property name as a string argument.\u003c/p\u003e\n"],["\u003cp\u003eTo use the extracted property value in further computations, it needs to be explicitly cast to the appropriate data type using methods like \u003ccode\u003egetString()\u003c/code\u003e, \u003ccode\u003egetNumber()\u003c/code\u003e, or \u003ccode\u003egetArray()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eset()\u003c/code\u003e method can be used to add or update properties of an \u003ccode\u003eImageCollection\u003c/code\u003e, accepting either a dictionary or key-value pairs.\u003c/p\u003e\n"],["\u003cp\u003eProperties of an \u003ccode\u003eImageCollection\u003c/code\u003e can be viewed as a dictionary using the \u003ccode\u003etoDictionary()\u003c/code\u003e method.\u003c/p\u003e\n"]]],[],null,["# ee.ImageCollection.getArray\n\nExtract a property from a feature.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------|---------|\n| ImageCollection.getArray`(property)` | Array |\n\n| Argument | Type | Details |\n|----------------|---------|-------------------------------------------|\n| this: `object` | Element | The feature to extract the property from. |\n| `property` | String | The property to extract. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A contrived, empty image collection for simple demonstration.\nvar col = ee.ImageCollection([]);\nprint('Collection without properties', col);\n\n// Set collection properties using a dictionary.\ncol = col.set({\n project_name: 'biomass_tracking',\n project_id: 3,\n plot_ids: ee.Array([7, 11, 20])\n});\n\n// Set collection properties using a series of key-value pairs.\ncol = col.set('project_year', 2018,\n 'rgb_vis', 'false_color');\n\nprint('Collection with properties', col);\n\n// Get a dictionary of collection property keys and values.\nprint('Property keys and values (ee.Dictionary)', col.toDictionary());\n\n// Get the value of a collection property. To use the result of\n// ee.ImageCollection.get in further computation, you need to cast it to the\n// appropriate class, for example, ee.Number(result) or ee.String(result).\nprint('Project ID (ambiguous object)', col.get('project_id'));\n\n// Get the value of a string collection property as an ee.String object.\nprint('Project name (ee.String)', col.getString('project_name'));\n\n// Get the value of a numeric collection property as an ee.Number object.\nprint('Project year (ee.Number)', col.getNumber('project_year'));\n\n// Get the value of an ee.Array collection property as an ee.Array object.\nprint('Plot IDs (ee.Array)', col.getArray('plot_ids'));\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 contrived, empty image collection for simple demonstration.\ncol = ee.ImageCollection([])\nprint('Collection without properties:')\npprint(col.getInfo())\n\n# Set collection properties using a dictionary.\ncol = col.set({\n 'project_name': 'biomass_tracking',\n 'project_id': 3,\n 'plot_ids': ee.Array([7, 11, 20])\n})\n\n# Set collection properties using a series of key-value pairs.\ncol = col.set('project_year', 2018,\n 'rgb_vis', 'false_color')\n\nprint('Collection with properties:')\npprint(col.getInfo())\n\n# Get a dictionary of collection property keys and values.\nprint('Property keys and values (ee.Dictionary):')\npprint(col.toDictionary().getInfo())\n\n# Get the value of a collection property. To use the result of\n# ee.ImageCollection.get in further computation, you need to cast it to the\n# appropriate class, for example, ee.Number(result) or ee.String(result).\nprint('Project ID (ambiguous object):', col.get('project_id').getInfo())\n\n# Get the value of a string collection property as an ee.String object.\nprint('Project name (ee.String):', col.getString('project_name').getInfo())\n\n# Get the value of a numeric collection property as an ee.Number object.\nprint('Project year (ee.Number):', col.getNumber('project_year').getInfo())\n\n# Get the value of an ee.Array collection property as an ee.Array object.\nprint('Plot IDs (ee.Array):', col.getArray('plot_ids').getInfo())\n```"]]