公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.FeatureCollection.distinct
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从集合中移除重复项。请注意,系统会根据所选属性的序列化形式的强哈希值来确定重复项。
用法 | 返回 |
---|
FeatureCollection.distinct(properties) | FeatureCollection |
参数 | 类型 | 详细信息 |
---|
此:collection | FeatureCollection | 从中选择对象的输入集合。 |
properties | 对象 | 用于比较的属性名称或属性名称列表。可以添加“.geo”属性来比较对象几何图形。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
print('FeatureCollection of power plants in Belgium', fc);
// Remove duplicate features according to property values.
print('Distinct based on a single property', fc.distinct('fuel1'));
print('Distinct based on two properties', fc.distinct(['fuel1', 'source']));
print('Distinct based on geometry', fc.distinct('.geo'));
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"')
print('FeatureCollection of power plants in Belgium:', fc.getInfo())
# Remove duplicate features according to property values.
print('Distinct based on a single property:', fc.distinct('fuel1').getInfo())
print('Distinct based on two properties:',
fc.distinct(['fuel1', 'source']).getInfo())
print('Distinct based on geometry', fc.distinct('.geo').getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003edistinct()\u003c/code\u003e method removes duplicate features from a FeatureCollection based on specified properties or geometry.\u003c/p\u003e\n"],["\u003cp\u003eDuplicates are identified using a strong hash of the serialized form of the selected properties or '.geo' for geometry.\u003c/p\u003e\n"],["\u003cp\u003eThe method accepts a property name, a list of property names, or '.geo' as input for comparison.\u003c/p\u003e\n"],["\u003cp\u003eIt returns a new FeatureCollection containing only the unique features.\u003c/p\u003e\n"],["\u003cp\u003eThe original FeatureCollection remains unchanged.\u003c/p\u003e\n"]]],["The `distinct` method removes duplicate features from a `FeatureCollection`. Duplicates are identified by comparing the serialized form of specified properties using a strong hash. The `properties` argument defines the comparison criteria, accepting a single property name or a list, including '.geo' for geometry. The method returns a new `FeatureCollection` with the duplicates removed. Examples are provided for both JavaScript and Python, using power plants in Belgium and properties like 'fuel1', 'source' or geometry to remove duplicates.\n"],null,["# ee.FeatureCollection.distinct\n\nRemoves duplicates from a collection. Note that duplicates are determined using a strong hash over the serialized form of the selected properties.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------|-------------------|\n| FeatureCollection.distinct`(properties)` | FeatureCollection |\n\n| Argument | Type | Details |\n|--------------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| this: `collection` | FeatureCollection | The input collection from which objects will be selected. |\n| `properties` | Object | A property name or a list of property names to use for comparison. The '.geo' property can be included to compare object geometries. |\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\"');\nprint('FeatureCollection of power plants in Belgium', fc);\n\n// Remove duplicate features according to property values.\nprint('Distinct based on a single property', fc.distinct('fuel1'));\nprint('Distinct based on two properties', fc.distinct(['fuel1', 'source']));\nprint('Distinct based on geometry', fc.distinct('.geo'));\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\"')\nprint('FeatureCollection of power plants in Belgium:', fc.getInfo())\n\n# Remove duplicate features according to property values.\nprint('Distinct based on a single property:', fc.distinct('fuel1').getInfo())\nprint('Distinct based on two properties:',\n fc.distinct(['fuel1', 'source']).getInfo())\nprint('Distinct based on geometry', fc.distinct('.geo').getInfo())\n```"]]