ee.List.frequency

:傳回清單中與元素相等的元素數。

用量傳回
List.frequency(element)整數
引數類型詳細資料
這個:list清單
element物件

範例

程式碼編輯器 (JavaScript)

// An ee.Image list object.
var list = ee.List([0, 1, 2, 2, 3, 4]);
print('List of integers', list);

// The ee.List.frequency function is used to determine how many times a value is
// present in a list, e.g. what is the frequency of 0, 2, and 9 in the list.
print('Frequency of value 0', list.frequency(0));
print('Frequency of value 2', list.frequency(2));
print('Frequency of value 9', list.frequency(9));

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# An ee.Image list object.
ee_list = ee.List([0, 1, 2, 2, 3, 4])
print('List of integer:', ee_list.getInfo())

# The ee.List.frequency function is used to determine how many times a value is
# present in a list, e.g. what is the frequency of 0, 2, and 9 in the list.
print('Frequency of value 0:', ee_list.frequency(0).getInfo())
print('Frequency of value 2:', ee_list.frequency(2).getInfo())
print('Frequency of value 9:', ee_list.frequency(9).getInfo())