公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.FeatureCollection.select
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从集合中的每个功能中选择属性。也可以仅使用字符串实参来调用此函数;这些实参都将被解读为 propertySelectors(可变实参)。
返回具有所选属性的要素集合。
用法 | 返回 |
---|
FeatureCollection.select(propertySelectors, newProperties, retainGeometry) | FeatureCollection |
参数 | 类型 | 详细信息 |
---|
此:featurecollection | FeatureCollection | FeatureCollection 实例。 |
propertySelectors | List<String> | 一个名称或正则表达式列表,用于指定要选择的属性。 |
newProperties | List<String>,可选 | 输出属性的新名称列表。必须与所选属性的数量一致。 |
retainGeometry | 布尔值,可选 | 如果为 false,结果将具有 NULL 几何图形。默认值为 true。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Select a single property.
var singleProp = fc.select('fuel1');
print('Single property selected',
singleProp.first());
// Select multiple properties.
var multiProp = fc.select(['fuel1', 'capacitymw']);
print('Multiple properties selected',
multiProp.first());
// Select multiple properties and rename them.
var multiPropRename = fc.select({
propertySelectors: ['fuel1', 'capacitymw'],
newProperties: ['Fuel_1', 'Capacity_MW']
});
print('Multiple properties selected, renamed',
multiPropRename.first());
// Select multiple properties, remove geometry.
var multiPropNoGeom = fc.select({
propertySelectors: ['fuel1', 'capacitymw'],
retainGeometry: false
});
print('Multiple properties selected, geometry removed',
multiPropNoGeom.first());
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"')
# Select a single property.
single_prop = fc.select('fuel1')
print('Single property selected:', single_prop.first().getInfo())
# Select multiple properties.
multi_prop = fc.select(['fuel1', 'capacitymw'])
print('Multiple properties selected:', multi_prop.first().getInfo())
# Select multiple properties and rename them.
multi_prop_rename = fc.select(**{
'propertySelectors': ['fuel1', 'capacitymw'],
'newProperties': ['Fuel_1', 'Capacity_MW']
})
print('Multiple properties selected, renamed:',
multi_prop_rename.first().getInfo())
# Select multiple properties, remove geometry.
multi_prop_no_geom = fc.select(**{
'propertySelectors': ['fuel1', 'capacitymw'],
'retainGeometry': False
})
print('Multiple properties selected, geometry removed:',
multi_prop_no_geom.first().getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eFeatureCollection.select()\u003c/code\u003e allows you to select specific properties (attributes) from each feature within a FeatureCollection.\u003c/p\u003e\n"],["\u003cp\u003eYou can select properties by their names, rename them, and optionally retain or remove the feature's geometry.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts arguments like \u003ccode\u003epropertySelectors\u003c/code\u003e for specifying properties to select, \u003ccode\u003enewProperties\u003c/code\u003e for renaming them, and \u003ccode\u003eretainGeometry\u003c/code\u003e to control geometry inclusion.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a new FeatureCollection containing only the selected properties (and potentially modified geometry) for each feature.\u003c/p\u003e\n"]]],[],null,["# ee.FeatureCollection.select\n\n\u003cbr /\u003e\n\nSelect properties from each Feature in a collection. It is also possible to call this function with only string arguments; they will be all be interpreted as propertySelectors (varargs).\n\n\u003cbr /\u003e\n\nReturns the feature collection with selected properties.\n\n| Usage | Returns |\n|---------------------------------------------------------------------------------------|-------------------|\n| FeatureCollection.select`(propertySelectors, `*newProperties* `, `*retainGeometry*`)` | FeatureCollection |\n\n| Argument | Type | Details |\n|---------------------------|--------------------------|----------------------------------------------------------------------------------------------|\n| this: `featurecollection` | FeatureCollection | The FeatureCollection instance. |\n| `propertySelectors` | List\\\u003cString\\\u003e | A list of names or regexes specifying the attributes to select. |\n| `newProperties` | List\\\u003cString\\\u003e, optional | A list of new names for the output properties. Must match the number of properties selected. |\n| `retainGeometry` | Boolean, optional | When false, the result will have a NULL geometry. Defaults to true. |\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// Select a single property.\nvar singleProp = fc.select('fuel1');\nprint('Single property selected',\n singleProp.first());\n\n// Select multiple properties.\nvar multiProp = fc.select(['fuel1', 'capacitymw']);\nprint('Multiple properties selected',\n multiProp.first());\n\n// Select multiple properties and rename them.\nvar multiPropRename = fc.select({\n propertySelectors: ['fuel1', 'capacitymw'],\n newProperties: ['Fuel_1', 'Capacity_MW']\n});\nprint('Multiple properties selected, renamed',\n multiPropRename.first());\n\n// Select multiple properties, remove geometry.\nvar multiPropNoGeom = fc.select({\n propertySelectors: ['fuel1', 'capacitymw'],\n retainGeometry: false\n});\nprint('Multiple properties selected, geometry removed',\n multiPropNoGeom.first());\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\n# FeatureCollection of power plants in Belgium.\nfc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(\n 'country_lg == \"Belgium\"')\n\n# Select a single property.\nsingle_prop = fc.select('fuel1')\nprint('Single property selected:', single_prop.first().getInfo())\n\n# Select multiple properties.\nmulti_prop = fc.select(['fuel1', 'capacitymw'])\nprint('Multiple properties selected:', multi_prop.first().getInfo())\n\n# Select multiple properties and rename them.\nmulti_prop_rename = fc.select(**{\n 'propertySelectors': ['fuel1', 'capacitymw'],\n 'newProperties': ['Fuel_1', 'Capacity_MW']\n })\nprint('Multiple properties selected, renamed:',\n multi_prop_rename.first().getInfo())\n\n# Select multiple properties, remove geometry.\nmulti_prop_no_geom = fc.select(**{\n 'propertySelectors': ['fuel1', 'capacitymw'],\n 'retainGeometry': False\n })\nprint('Multiple properties selected, geometry removed:',\n multi_prop_no_geom.first().getInfo())\n```"]]