ee.List.filter

Lọc danh sách chỉ những phần tử khớp với bộ lọc đã cho. Để lọc các mục danh sách không phải là hình ảnh hoặc tính năng, hãy kiểm thử một thuộc tính có tên là "item", ví dụ: ee.Filter.gt('item', 3).

Cách sử dụngGiá trị trả về
List.filter(filter)Danh sách
Đối sốLoạiThông tin chi tiết
this: listDanh sách
filterLọc

Ví dụ

Trình soạn thảo mã (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))));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap để phát triển tương tác.

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.
print('List items equal to 3:',
      ee_list.filter(ee.Filter.eq('item', 3)).getInfo())
print('List items greater than 4:',
      ee_list.filter(ee.Filter.gt('item', 4)).getInfo())
print('List items not None:',
      ee_list.filter(ee.Filter.notNull(['item'])).getInfo())
print('List items in another list:',
      ee_list.filter(ee.Filter.inList('item', [1, 98, 99])).getInfo())
print('List items 3 ≤ 𝑥 ≤ 6:',
      ee_list.filter(ee.Filter.And(
          ee.Filter.gte('item', 3),
          ee.Filter.lte('item', 6))).getInfo())