Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.FeatureCollection.distinct
Stay organized with collections
Save and categorize content based on your preferences.
Removes duplicates from a collection. Note that duplicates are determined using a strong hash over the serialized form of the selected properties.
Usage | Returns | FeatureCollection.distinct(properties) | FeatureCollection |
Argument | Type | Details | this: collection | FeatureCollection | The input collection from which objects will be selected. |
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. |
Examples
Code Editor (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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["\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```"]]