ee.Array.argmax

Trả về vị trí (dưới dạng danh sách chỉ mục trong mỗi trục mảng) của giá trị lớn nhất trong một mảng hoặc giá trị rỗng nếu mảng đó trống. Nếu có nhiều lần xuất hiện giá trị tối đa, hàm sẽ trả về vị trí của giá trị đầu tiên.

Cách sử dụngGiá trị trả về
Array.argmax()Danh sách
Đối sốLoạiThông tin chi tiết
this: arrayMảng

Ví dụ

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

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 cho quá trình phát triển tương tác.

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]