Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eee.Filter.hasType\u003c/code\u003e creates a filter that checks if data has a specified type or is a subtype of it.\u003c/p\u003e\n"],["\u003cp\u003eThis filter can be applied to properties or geometries within a FeatureCollection.\u003c/p\u003e\n"],["\u003cp\u003eThe filter is constructed by defining the operand (property or geometry) and the expected type.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eleftField\u003c/code\u003e selects the property or geometry to check, while \u003ccode\u003erightValue\u003c/code\u003e defines the expected type.\u003c/p\u003e\n"]]],["`ee.Filter.hasType` creates a filter to check if a left operand's type matches or is a subtype of the type specified by the right operand. It accepts `leftField` or `leftValue` to select the left operand and `rightValue` or `rightField` for the right operand. The function returns a `Filter` object. Examples demonstrate filtering a feature collection based on the type of a geometry or the type of a property like Number or String.\n"],null,["# ee.Filter.hasType\n\nCreates a unary or binary filter that passes if the left operand has the type, or is a subtype of the type named in the right operand.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------------------------------------------------------|---------|\n| `ee.Filter.hasType(`*leftField* `, `*rightValue* `, `*rightField* `, `*leftValue*`)` | Filter |\n\n| Argument | Type | Details |\n|--------------|-----------------------|---------------------------------------------------------------------------------------|\n| `leftField` | String, default: null | A selector for the left operand. Should not be specified if leftValue is specified. |\n| `rightValue` | Object, default: null | The value of the right operand. Should not be specified if rightField is specified. |\n| `rightField` | String, default: null | A selector for the right operand. Should not be specified if rightValue is specified. |\n| `leftValue` | Object, default: null | The value of the left operand. Should not be specified if leftField is specified. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar fc = ee.FeatureCollection([\n ee.Feature(ee.Geometry.Rectangle([0, 0, 1, 1]), {'x': 0}),\n ee.Feature(ee.Geometry.Rectangle(0, 0, 3, 3), {'x': 'foo'}),\n ee.Feature(ee.Geometry.Point(0, 0))]);\n\n// The third feature has a Point geometry.\nprint(fc.filter(ee.Filter.hasType({leftField: '.geo', rightValue: 'Point'})));\n\n// The first two features have a Polygon geometry.\nprint(fc.filter(ee.Filter.hasType({leftField: '.geo', rightValue: 'Polygon'})));\n\n// The first feature has property x with type Number.\nprint(fc.filter(ee.Filter.hasType({leftField: 'x', rightValue: 'Number'})));\n\n// The second feature has property x with type String.\nprint(fc.filter(ee.Filter.hasType({leftField: 'x', rightValue: 'String'})));\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\nfc = ee.FeatureCollection([\n ee.Feature(ee.Geometry.Rectangle([0, 0, 1, 1]), {'x': 0}),\n ee.Feature(ee.Geometry.Rectangle(0, 0, 3, 3), {'x': 'foo'}),\n ee.Feature(ee.Geometry.Point(0, 0)),\n])\n\n# The third feature has a Point geometry.\ndisplay(\n fc.filter(ee.Filter.hasType(leftField='.geo', rightValue='Point')).getInfo()\n)\n\n# The first two features have a Polygon geometry.\ndisplay(\n fc.filter(\n ee.Filter.hasType(leftField='.geo', rightValue='Polygon')\n ).getInfo()\n)\n\n# The first feature has property x with type Number.\ndisplay(\n fc.filter(ee.Filter.hasType(leftField='x', rightValue='Number')).getInfo()\n)\n\n# The second feature has property x with type String.\ndisplay(\n fc.filter(ee.Filter.hasType(leftField='x', rightValue='String')).getInfo()\n)\n```"]]