Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.FeatureCollection.filter
Stay organized with collections
Save and categorize content based on your preferences.
Apply a filter to this collection.
Returns the filtered collection.
Usage | Returns | FeatureCollection.filter(filter) | Collection |
Argument | Type | Details | this: collection | Collection | The Collection instance. |
filter | Filter | A filter to apply to this collection. |
Examples
Code Editor (JavaScript)
// Get Denver county polygon.
var denver = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2')
.filter("ADM2_NAME == 'Denver'")
.filter(ee.Filter.eq('ADM2_NAME', 'Denver')) // Exactly the same as above.
.first()
.geometry();
Map.centerObject(denver, 9);
Map.addLayer(denver, null, 'Denver');
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)
# Get Denver county polygon.
denver = (
ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2')
.filter("ADM2_NAME == 'Denver'")
.filter(ee.Filter.eq('ADM2_NAME', 'Denver')) # Exactly the same as above.
.first()
.geometry()
)
m = geemap.Map()
m.center_object(denver, 9)
m.add_layer(denver, None, 'Denver')
m
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\u003e\u003ccode\u003efilter()\u003c/code\u003e returns a filtered version of the original Earth Engine FeatureCollection based on the provided filter criteria.\u003c/p\u003e\n"],["\u003cp\u003eThe filter can be specified using a string expression (e.g., "ADM2_NAME == 'Denver'") or an \u003ccode\u003eee.Filter\u003c/code\u003e object (e.g., \u003ccode\u003eee.Filter.eq('ADM2_NAME', 'Denver')\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThis method allows for the selection of specific features within a collection based on their properties.\u003c/p\u003e\n"],["\u003cp\u003eThe examples demonstrate how to filter a FeatureCollection to obtain a specific feature's geometry (Denver county) and display it on a map.\u003c/p\u003e\n"]]],["The content details how to apply a filter to a `FeatureCollection`, which returns a filtered collection. The `filter` argument, of type `Filter`, is applied to the `Collection` instance. Examples in JavaScript and Python demonstrate filtering a collection to find the 'Denver' county polygon using `.filter()`. This filtering can be done directly using the parameter name and value or using `ee.Filter.eq()` and is applied to the \"ADM2_NAME\" parameter.\n"],null,["# ee.FeatureCollection.filter\n\n\u003cbr /\u003e\n\nApply a filter to this collection.\n\n\u003cbr /\u003e\n\nReturns the filtered collection.\n\n| Usage | Returns |\n|------------------------------------|------------|\n| FeatureCollection.filter`(filter)` | Collection |\n\n| Argument | Type | Details |\n|--------------------|------------|---------------------------------------|\n| this: `collection` | Collection | The Collection instance. |\n| `filter` | Filter | A filter to apply to this collection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Get Denver county polygon.\nvar denver = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2')\n .filter(\"ADM2_NAME == 'Denver'\")\n .filter(ee.Filter.eq('ADM2_NAME', 'Denver')) // Exactly the same as above.\n .first()\n .geometry();\n\nMap.centerObject(denver, 9);\nMap.addLayer(denver, null, 'Denver');\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# Get Denver county polygon.\ndenver = (\n ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2')\n .filter(\"ADM2_NAME == 'Denver'\")\n .filter(ee.Filter.eq('ADM2_NAME', 'Denver')) # Exactly the same as above.\n .first()\n .geometry()\n)\n\nm = geemap.Map()\nm.center_object(denver, 9)\nm.add_layer(denver, None, 'Denver')\nm\n```"]]