ee.Array.byte

Trên cơ sở từng phần tử, truyền giá trị đầu vào thành số nguyên 8 bit không dấu.

Cách sử dụngGiá trị trả về
Array.byte()Mảng
Đối sốLoạiThông tin chi tiết
this: inputMảngMảng đầu vào.

Ví dụ

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

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)

# 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())  # [[], []]