ee.Array.first

以元素為單位,選取第一個值的值。

用量傳回
Array.first(right)陣列
引數類型詳細資料
這個:left陣列左側值。
right陣列右側值。

範例

程式碼編輯器 (JavaScript)

var empty = ee.Array([], ee.PixelType.int8());
print(empty.first(empty));  // []

print(ee.Array([0]).first(0));  // [0]
print(ee.Array([0, 1, 2]).first(1));  // [0,1,2]
print(ee.Array([0, 1, 2]).first(ee.Array([3, 4, 5])));  // [0,1,2]
print(ee.Array([3, 4, 5]).first(ee.Array([0, 1, 2])));  // [3,4,5]

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

empty = ee.Array([], ee.PixelType.int8())
display(empty.first(empty))  # []

display(ee.Array([0]).first(0))  # [0]
display(ee.Array([0, 1, 2]).first(1))  # [0,1,2]
display(ee.Array([0, 1, 2]).first(ee.Array([3, 4, 5])))  # [0, 1, 2]
display(ee.Array([3, 4, 5]).first(ee.Array([0, 1, 2])))  # [3, 4, 5]