ee.List.filter
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Filtruje listę tak, aby zawierała tylko elementy pasujące do danego filtra. Aby odfiltrować elementy listy, które nie są obrazami ani funkcjami, przetestuj właściwość o nazwie „item”, np. ee.Filter.gt(„item”, 3).
Wykorzystanie | Zwroty |
---|
List.filter(filter) | Lista |
Argument | Typ | Szczegóły |
---|
to: list | Lista | |
filter | Filtr | |
Przykłady
Edytor kodu (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))));
Konfiguracja Pythona
Informacje o interfejsie Python API i o używaniu pakietu geemap
do programowania interaktywnego znajdziesz na stronie
Python Environment.
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())
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-25 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-25 UTC."],[[["\u003cp\u003e\u003ccode\u003eList.filter()\u003c/code\u003e filters a list to retain only elements matching a specified filter.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003efilter\u003c/code\u003e argument accepts an \u003ccode\u003eee.Filter\u003c/code\u003e object defining the filtering criteria.\u003c/p\u003e\n"],["\u003cp\u003eUse the property name 'item' within the \u003ccode\u003eee.Filter\u003c/code\u003e to refer to individual list elements.\u003c/p\u003e\n"],["\u003cp\u003eThis function is applicable to lists of any data type, including numbers, strings, and objects.\u003c/p\u003e\n"]]],["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"],null,["# ee.List.filter\n\nFilters a list to only the elements that match the given filter. To filter list items that aren't images or features, test a property named 'item', e.g., ee.Filter.gt('item', 3).\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------|---------|\n| List.filter`(filter)` | List |\n\n| Argument | Type | Details |\n|--------------|--------|---------|\n| this: `list` | List | |\n| `filter` | Filter | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// An ee.Image list object.\nvar list = ee.List([1, 2, 3, null, 6, 7]);\n\n// Filter the list by a variety of conditions. Note that the property name\n// 'item' is used to refer to list elements in ee.Filter functions.\nprint('List items equal to 3',\n list.filter(ee.Filter.eq('item', 3)));\nprint('List items greater than 4',\n list.filter(ee.Filter.gt('item', 4)));\nprint('List items not null',\n list.filter(ee.Filter.notNull(['item'])));\nprint('List items in another list',\n list.filter(ee.Filter.inList('item', [1, 98, 99])));\nprint('List items 3 ≤ 𝑥 ≤ 6',\n list.filter(ee.Filter.and(\n ee.Filter.gte('item', 3),\n ee.Filter.lte('item', 6))));\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\n# An ee.Image list object.\nee_list = ee.List([1, 2, 3, None, 6, 7])\n\n# Filter the list by a variety of conditions. Note that the property name\n# 'item' is used to refer to list elements in ee.Filter functions.\nprint('List items equal to 3:',\n ee_list.filter(ee.Filter.eq('item', 3)).getInfo())\nprint('List items greater than 4:',\n ee_list.filter(ee.Filter.gt('item', 4)).getInfo())\nprint('List items not None:',\n ee_list.filter(ee.Filter.notNull(['item'])).getInfo())\nprint('List items in another list:',\n ee_list.filter(ee.Filter.inList('item', [1, 98, 99])).getInfo())\nprint('List items 3 ≤ 𝑥 ≤ 6:',\n ee_list.filter(ee.Filter.And(\n ee.Filter.gte('item', 3),\n ee.Filter.lte('item', 6))).getInfo())\n```"]]