公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Array
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回具有指定坐标的数组。
用法 | 返回 |
---|
ee.Array(values, pixelType) | 数组 |
参数 | 类型 | 详细信息 |
---|
values | 对象 | 要转换的现有数组,或要从中创建数组的数字/数字列表/任意深度的嵌套数字列表。对于嵌套列表,同一深度的所有内部数组必须具有相同的长度,并且数字只能出现在最深层。 |
pixelType | PixelType,默认值: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]
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eee.Array\u003c/code\u003e creates an array from given values, which can be numbers, lists, or nested lists, and optionally specifies the data type of the array elements.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evalues\u003c/code\u003e argument can be an existing array, a single number, a list of numbers, or a nested list of numbers, representing the array's data.\u003c/p\u003e\n"],["\u003cp\u003eAn optional \u003ccode\u003epixelType\u003c/code\u003e argument specifies the data type of the array elements, which is inferred if not provided but mandatory for empty arrays.\u003c/p\u003e\n"],["\u003cp\u003eNested lists used in the \u003ccode\u003evalues\u003c/code\u003e argument must have consistent inner array lengths at the same depth, with numbers only at the deepest level.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eee.Array\u003c/code\u003e can also be used to cast an existing \u003ccode\u003eee.Array\u003c/code\u003e to a new \u003ccode\u003eee.Array\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# ee.Array\n\nReturns an array with the given coordinates.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------|---------|\n| `ee.Array(values, `*pixelType*`)` | Array |\n\n| Argument | Type | Details |\n|-------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `values` | Object | An existing array to cast, or a number/list of numbers/nested list of numbers of any depth to create an array from. For nested lists, all inner arrays at the same depth must have the same length and numbers may only be present at the deepest level. |\n| `pixelType` | PixelType, default: null | The type of each number in the values argument. If the pixel type is not provided, it will be inferred from the numbers in 'values'. If there aren't any numbers in 'values', this type must be provided. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Requires an explicit PixelType if no data.\nprint(ee.Array([], ee.PixelType.int8())); // Empty []\nprint(ee.Array([[]], ee.PixelType.uint8())); // Empty [[]]\nprint(ee.Array([[], []], ee.PixelType.float())); // Empty [[], []]\n\n// 1-D Arrays\nprint(ee.Array([0])); // [0]\nprint(ee.Array([0, 1])); // [0, 1]\n// 2-D Arrays\nprint(ee.Array([[1]])); // [[1]]\nprint(ee.Array([[0, 1], [2, 3]])); // [[0,1],[2,3]]\n\n// Arrays from ee.Number.\nprint(ee.Array([ee.Number(123).toUint8()])); // [123]\n\n// Lists are useful ways to construct larger Arrays.\nprint(ee.Array(ee.List.sequence(0, 10, 2))); // // [0,2,4,6,8,10]\n\n// Arrays can be used to make Arrays.\nvar array1D = ee.Array([1, 2, 3]);\n// This is a cast.\nprint(ee.Array(array1D)); // [1,2,3]\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Requires an explicit PixelType if no data.\nprint(ee.Array([], ee.PixelType.int8()).getInfo()) # Empty []\nprint(ee.Array([[]], ee.PixelType.uint8()).getInfo()) # Empty [[]]\nprint(ee.Array([[], []], ee.PixelType.float()).getInfo()) # Empty [[], []]\n\n# 1-D Arrays\nprint(ee.Array([0]).getInfo()) # [0]\nprint(ee.Array([0, 1]).getInfo()) # [0, 1]\n# 2-D Arrays\nprint(ee.Array([[1]]).getInfo()) # [[1]]\nprint(ee.Array([[0, 1], [2, 3]]).getInfo()) # [[0,1],[2,3]]\n\n# Arrays from ee.Number.\nprint(ee.Array([ee.Number(123).toUint8()]).getInfo()) # [123]\n\n# Lists are useful ways to construct larger Arrays.\nprint(ee.Array(ee.List.sequence(0, 10, 2)).getInfo()) # [0, 2, 4, 6, 8, 10]\n\n# Arrays can be used to make Arrays.\narray_one = ee.Array([1, 2, 3])\n# This is a cast.\nprint(ee.Array(array_one).getInfo()) # [1, 2, 3]\n```"]]