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 API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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