ee.Array.byte

以元素為單位,將輸入值轉換為未簽署的 8 位元整數。

用量傳回
Array.byte()陣列
引數類型詳細資料
這個:input陣列輸入陣列。

範例

程式碼編輯器 (JavaScript)

// Clamps below at 0.
print(ee.Array([-1]).byte());  // [0]
print(ee.Array([255]).byte());  // [255]
// Clamps above at 255.
print(ee.Array([256]).byte());  // [255]

// Rounds. [0,0,1,127,255,255]
print(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte());

// Requires an explicit PixelType if no data.
print(ee.Array([[], []], ee.PixelType.float()).byte());  // Empty [[], []]

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# Clamps below at 0.
display(ee.Array([-1]).byte())  # [0]
display(ee.Array([255]).byte())  # [255]
# Clamps above at 255.
display(ee.Array([256]).byte())  # [255]

# Rounds. [0, 0, 1, 127, 255, 255]
display(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte())

# Requires an explicit PixelType if no data.
display(ee.Array([[], []], ee.PixelType.float()).byte())  # [[], []]