Announcement : On
November 13, 2024 , all users will need to
use a Cloud project in order to access Earth Engine. After this date, continued individual access without a Cloud project will require
an exception .
Send feedback
ee.Filter.hasType
Stay organized with collections
Save and categorize content based on your preferences.
Creates 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.
Usage Returns ee.Filter.hasType(leftField , rightValue , rightField , leftValue )
Filter
Argument Type Details leftField
String, default: null A selector for the left operand. Should not be specified if leftValue is specified. rightValue
Object, default: null The value of the right operand. Should not be specified if rightField is specified. rightField
String, default: null A selector for the right operand. Should not be specified if rightValue is specified. leftValue
Object, default: null The value of the left operand. Should not be specified if leftField is specified.
Examples
Code Editor (JavaScript)
var fc = ee.FeatureCollection([
ee.Feature(ee.Geometry.Rectangle([0, 0, 1, 1]), {'x': 0}),
ee.Feature(ee.Geometry.Rectangle(0, 0, 3, 3), {'x': 'foo'}),
ee.Feature(ee.Geometry.Point(0, 0))]);
// The third feature has a Point geometry.
print(fc.filter(ee.Filter.hasType({leftField: '.geo', rightValue: 'Point'})));
// The first two features have a Polygon geometry.
print(fc.filter(ee.Filter.hasType({leftField: '.geo', rightValue: 'Polygon'})));
// The first feature has property x with type Number.
print(fc.filter(ee.Filter.hasType({leftField: 'x', rightValue: 'Number'})));
// The second feature has property x with type String.
print(fc.filter(ee.Filter.hasType({leftField: 'x', rightValue: 'String'})));
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)
fc = ee.FeatureCollection([
ee.Feature(ee.Geometry.Rectangle([0, 0, 1, 1]), {'x': 0}),
ee.Feature(ee.Geometry.Rectangle(0, 0, 3, 3), {'x': 'foo'}),
ee.Feature(ee.Geometry.Point(0, 0)),
])
# The third feature has a Point geometry.
display(
fc.filter(ee.Filter.hasType(leftField='.geo', rightValue='Point')).getInfo()
)
# The first two features have a Polygon geometry.
display(
fc.filter(
ee.Filter.hasType(leftField='.geo', rightValue='Polygon')
).getInfo()
)
# The first feature has property x with type Number.
display(
fc.filter(ee.Filter.hasType(leftField='x', rightValue='Number')).getInfo()
)
# The second feature has property x with type String.
display(
fc.filter(ee.Filter.hasType(leftField='x', rightValue='String')).getInfo()
)
Send feedback
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.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{
"lastModified": "Last updated 2023-10-06 UTC.",
"confidential": False
}