ee.Array

返回具有指定坐标的数组。

用法返回
ee.Array(values, pixelType)数组
参数类型详细信息
values对象要转换的现有数组,或要从中创建数组的数字/数字列表/任意深度的嵌套数字列表。对于嵌套列表,同一深度的所有内部数组必须具有相同的长度,并且数字只能出现在最深层。
pixelTypePixelType,默认值:null“values”实参中每个数字的类型。如果未提供像素类型,系统将根据“values”中的数字推断出像素类型。如果“values”中没有任何数字,则必须提供此类型。

示例

代码编辑器 (JavaScript)

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

// 1-D Arrays
print(ee.Array([0]));  // [0]
print(ee.Array([0, 1]));  // [0, 1]
// 2-D Arrays
print(ee.Array([[1]]));  // [[1]]
print(ee.Array([[0, 1], [2, 3]]));  // [[0,1],[2,3]]

// Arrays from ee.Number.
print(ee.Array([ee.Number(123).toUint8()]));  // [123]

// Lists are useful ways to construct larger Arrays.
print(ee.Array(ee.List.sequence(0, 10, 2)));  // // [0,2,4,6,8,10]

// Arrays can be used to make Arrays.
var array1D = ee.Array([1, 2, 3]);
// This is a cast.
print(ee.Array(array1D));  // [1,2,3]

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

import ee
import geemap.core as geemap

Colab (Python)

# Requires an explicit PixelType if no data.
print(ee.Array([], ee.PixelType.int8()).getInfo())  # Empty []
print(ee.Array([[]], ee.PixelType.uint8()).getInfo())  # Empty [[]]
print(ee.Array([[], []], ee.PixelType.float()).getInfo())  # Empty [[], []]

# 1-D Arrays
print(ee.Array([0]).getInfo())  # [0]
print(ee.Array([0, 1]).getInfo())  # [0, 1]
# 2-D Arrays
print(ee.Array([[1]]).getInfo())  # [[1]]
print(ee.Array([[0, 1], [2, 3]]).getInfo())  # [[0,1],[2,3]]

# Arrays from ee.Number.
print(ee.Array([ee.Number(123).toUint8()]).getInfo())  # [123]

# Lists are useful ways to construct larger Arrays.
print(ee.Array(ee.List.sequence(0, 10, 2)).getInfo())  # [0, 2, 4, 6, 8, 10]

# Arrays can be used to make Arrays.
array_one = ee.Array([1, 2, 3])
# This is a cast.
print(ee.Array(array_one).getInfo())  # [1, 2, 3]