公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.FeatureCollection.makeArray
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
通过将每个功能的属性列表合并为一个一维数组,为集合中的每个功能添加一个一维数组。所有属性都必须是数值。如果某个特征不包含所有指定的属性,或者其中任何属性不是数值,则该特征将从结果集合中舍弃。
用法 | 返回 |
---|
FeatureCollection.makeArray(properties, name) | FeatureCollection |
参数 | 类型 | 详细信息 |
---|
此:collection | FeatureCollection | 从中选择属性的输入集合。 |
properties | 列表 | 要选择的属性。 |
name | 字符串,默认值:“array” | 新数组属性的名称。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// A list of feature properties to combine into an array
// (power generation by year).
var properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016'];
// Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year');
print('FeatureCollection with array of selected properties added', fc);
print('See example of new "gwh_by_year" property', fc.first().toDictionary());
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
from pprint import pprint
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"')
# A list of feature properties to combine into an array
# (power generation by year).
properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016']
# Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year')
print('FeatureCollection with array of selected properties added:',
fc.getInfo())
print('See example of new "gwh_by_year" property:')
pprint(fc.first().toDictionary().getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003emakeArray()\u003c/code\u003e combines specified numeric properties of features within a FeatureCollection into a new 1-D array property.\u003c/p\u003e\n"],["\u003cp\u003eFeatures lacking any of the specified properties, or containing non-numeric values in those properties, are excluded from the output.\u003c/p\u003e\n"],["\u003cp\u003eThe resulting FeatureCollection contains the original features with an added array property holding the combined values.\u003c/p\u003e\n"],["\u003cp\u003eThe array property is named using the 'name' argument, defaulting to "array" if not provided.\u003c/p\u003e\n"]]],[],null,["# ee.FeatureCollection.makeArray\n\nAdd a 1-D Array to each feature in a collection by combining a list of properties for each feature into a 1-D Array. All of the properties must be numeric values. If a feature doesn't contain all of the named properties, or any of them aren't numeric, the feature will be dropped from the resulting collection.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------------------------|-------------------|\n| FeatureCollection.makeArray`(properties, `*name*`)` | FeatureCollection |\n\n| Argument | Type | Details |\n|--------------------|--------------------------|--------------------------------------------------------------|\n| this: `collection` | FeatureCollection | The input collection from which properties will be selected. |\n| `properties` | List | The properties to select. |\n| `name` | String, default: \"array\" | The name of the new array property. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// FeatureCollection of power plants in Belgium.\nvar fc = ee.FeatureCollection('WRI/GPPD/power_plants')\n .filter('country_lg == \"Belgium\"');\n\n// A list of feature properties to combine into an array\n// (power generation by year).\nvar properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016'];\n\n// Add array of power-generation-by-year property to features.\nfc = fc.makeArray(properties, 'gwh_by_year');\n\nprint('FeatureCollection with array of selected properties added', fc);\nprint('See example of new \"gwh_by_year\" property', fc.first().toDictionary());\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# FeatureCollection of power plants in Belgium.\nfc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(\n 'country_lg == \"Belgium\"')\n\n# A list of feature properties to combine into an array\n# (power generation by year).\nproperties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016']\n\n# Add array of power-generation-by-year property to features.\nfc = fc.makeArray(properties, 'gwh_by_year')\n\nprint('FeatureCollection with array of selected properties added:',\n fc.getInfo())\nprint('See example of new \"gwh_by_year\" property:')\npprint(fc.first().toDictionary().getInfo())\n```"]]