Earth Engine 将推出
非商业配额层级,以保护共享计算资源并确保为所有人提供可靠的性能。所有非商业项目都需要在
2026 年 4 月 27 日之前选择配额层级,否则系统会默认使用 Community 层级。层级配额将于
2026 年 4 月 27 日对所有项目生效(无论层级选择日期如何)。
了解详情。
ee.List.filter
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
仅过滤出与给定过滤条件匹配的列表元素。如需过滤非图片或地图项的列表项,请测试名为“item”的属性,例如 ee.Filter.gt(“item”,3)。
| 用法 | 返回 |
|---|
List.filter(filter) | 列表 |
| 参数 | 类型 | 详细信息 |
|---|
this:list | 列表 | |
filter | 过滤 | |
示例
Code Editor (JavaScript)
// An ee.Image list object.
var list = ee.List([1, 2, 3, null, 6, 7]);
// Filter the list by a variety of conditions. Note that the property name
// 'item' is used to refer to list elements in ee.Filter functions.
print('List items equal to 3',
list.filter(ee.Filter.eq('item', 3)));
print('List items greater than 4',
list.filter(ee.Filter.gt('item', 4)));
print('List items not null',
list.filter(ee.Filter.notNull(['item'])));
print('List items in another list',
list.filter(ee.Filter.inList('item', [1, 98, 99])));
print('List items 3 ≤ 𝑥 ≤ 6',
list.filter(ee.Filter.and(
ee.Filter.gte('item', 3),
ee.Filter.lte('item', 6))));
Python 设置
如需了解 Python API 以及如何使用 geemap 进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# An ee.Image list object.
ee_list = ee.List([1, 2, 3, None, 6, 7])
# Filter the list by a variety of conditions. Note that the property name
# 'item' is used to refer to list elements in ee.Filter functions.
display('List items equal to 3:',
ee_list.filter(ee.Filter.eq('item', 3)))
display('List items greater than 4:',
ee_list.filter(ee.Filter.gt('item', 4)))
display('List items not None:',
ee_list.filter(ee.Filter.notNull(['item'])))
display('List items in another list:',
ee_list.filter(ee.Filter.inList('item', [1, 98, 99])))
display('List items 3 ≤ 𝑥 ≤ 6:',
ee_list.filter(ee.Filter.And(
ee.Filter.gte('item', 3),
ee.Filter.lte('item', 6))))
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-10-30。
[null,null,["最后更新时间 (UTC):2025-10-30。"],[],["The `List.filter(filter)` method filters a list, returning a new list containing only elements that match the provided filter. Elements are referenced by the property name 'item' within `ee.Filter` functions. Filters can test for equality (`eq`), greater than (`gt`), not null (`notNull`), inclusion in another list (`inList`), and combined conditions using `and`. Examples show how to filter numerical lists in both JavaScript and Python using these comparison operations.\n"]]