ee.Array.argmax

傳回陣列中最大值的位置 (以每個陣列軸的索引清單表示),如果陣列為空白,則傳回空值。如果最大值出現多次,則會傳回第一個最大值的位置。

用量傳回
Array.argmax()清單
引數類型詳細資料
這個:array陣列

範例

程式碼編輯器 (JavaScript)

// Return the position of the maximum value in each dimension.

// Returns null if the array is empty.
print(ee.Array([], ee.PixelType.int8()).argmax());  // null

print(ee.Array([9]).argmax());  // [0]
print(ee.Array([0, -1, 2, 1]).argmax());  // [2]
print(ee.Array([[3, 4, 2], [6, 5, 7]]).argmax());  // [1, 2]

// Returns the first occurrence of the maximum.
print(ee.Array([1, 1, 1, 9, 9, 9]).argmax());  // [3]

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# Return the position of the maximum value in each dimension.

# Returns null if the array is empty.
display(ee.Array([], ee.PixelType.int8()).argmax())  # None

display(ee.Array([9]).argmax())  # [0]
display(ee.Array([0, -1, 2, 1]).argmax())  # [2]
display(ee.Array([[3, 4, 2], [6, 5, 7]]).argmax())  # [1, 2]

# Returns the first occurrence of the maximum.
display(ee.Array([1, 1, 1, 9, 9, 9]).argmax())  # [3]