Earth Engine 将推出
非商业配额层级,以保护共享计算资源并确保为所有人提供可靠的性能。所有非商业项目都需要在
2026 年 4 月 27 日之前选择配额层级,否则系统会默认使用 Community 层级。层级配额将于
2026 年 4 月 27 日对所有项目生效(无论层级选择日期如何)。
了解详情。
ee.Filter.hasType
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建一元或二元过滤器,如果左侧操作数的类型为右侧操作数中命名的类型或该类型的子类型,则通过该过滤器。
| 用法 | 返回 |
|---|
ee.Filter.hasType(leftField, rightValue, rightField, leftValue) | 过滤 |
| 参数 | 类型 | 详细信息 |
|---|
leftField | 字符串,默认值:null | 左操作数的选择器。如果指定了 leftValue,则不应指定此参数。 |
rightValue | 对象,默认值:null | 右操作数的值。如果指定了 rightField,则不应指定此字段。 |
rightField | 字符串,默认值:null | 用于选择右操作数的选择器。如果指定了 rightValue,则不应指定此参数。 |
leftValue | 对象,默认值:null | 左操作数的值。如果指定了 leftField,则不应指定此字段。 |
示例
代码编辑器 (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 设置
如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅
Python 环境页面。
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'))
)
# The first two features have a Polygon geometry.
display(
fc.filter(
ee.Filter.hasType(leftField='.geo', rightValue='Polygon')
)
)
# The first feature has property x with type Number.
display(
fc.filter(ee.Filter.hasType(leftField='x', rightValue='Number'))
)
# The second feature has property x with type String.
display(
fc.filter(ee.Filter.hasType(leftField='x', rightValue='String'))
)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-10-30。
[null,null,["最后更新时间 (UTC):2025-10-30。"],[],["`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"]]