公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Array.cut
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
沿一个或多个轴剪切数组。
用法 | 返回 |
---|
Array.cut(position) | 数组 |
参数 | 类型 | 详细信息 |
---|
此:array | 数组 | 要剪切的数组。 |
position | 列表 | 沿一个或多个轴切割数组。位置实参可为数组的每个轴指定一个值,也可指定 -1 来表示整个轴。输出将是一个与输入具有相同维度的数组,其中在位置数组中不是 -1 的每个轴上的长度为 1。 |
示例
代码编辑器 (JavaScript)
print(ee.Array([9]).cut([0])); // [9]
print(ee.Array([9]).cut([-1])); // [9]
var array1x3 = ee.Array([0, 1, 2]);
print(array1x3.cut([-1])); // [0,1,2]
print(array1x3.cut([0])); // [0]
print(array1x3.cut([2])); // [2]
var array2x3 = ee.Array([[0, 1, 2], [3, 4, 5]]);
print(array2x3.cut([-1, -1])); // [[0,1,2],[3,4,5]]
print(array2x3.cut([-1, 0])); // [[0],[3]]
print(array2x3.cut([1, -1])); // [[3,4,5]]
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
display(ee.Array([9]).cut([0])) # [9]
display(ee.Array([9]).cut([-1])) # [9]
array1x3 = ee.Array([0, 1, 2])
display(array1x3.cut([-1])) # [0, 1, 2]
display(array1x3.cut([0])) # [0]
display(array1x3.cut([2])) # [2]
array2x3 = ee.Array([[0, 1, 2], [3, 4, 5]])
display(array2x3.cut([-1, -1])) # [[0, 1, 2], [3 , 4, 5]]
display(array2x3.cut([-1, 0])) # [[0], [3]]
display(array2x3.cut([1, -1])) # [[3, 4, 5]]
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eArray.cut()\u003c/code\u003e extracts a portion of an array along specified axes.\u003c/p\u003e\n"],["\u003cp\u003eIt takes a \u003ccode\u003eposition\u003c/code\u003e argument, a list indicating cut points on each axis.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003e-1\u003c/code\u003e in the \u003ccode\u003eposition\u003c/code\u003e list selects the entire axis.\u003c/p\u003e\n"],["\u003cp\u003eThe output is a new array with reduced dimensions based on the cut points.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eArray.cut()\u003c/code\u003e is useful for slicing and dicing multi-dimensional arrays within Earth Engine.\u003c/p\u003e\n"]]],[],null,["# ee.Array.cut\n\nCut an array along one or more axes.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------|---------|\n| Array.cut`(position)` | Array |\n\n| Argument | Type | Details |\n|---------------|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `array` | Array | The array to cut. |\n| `position` | List | Cut an array along one or more axes. The positions args specifies either a single value for each axis of the array, or -1, indicating the whole axis. The output will be an array that has the same dimensions as the input, with a length of 1 on each axis that was not -1 in the positions array. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint(ee.Array([9]).cut([0])); // [9]\nprint(ee.Array([9]).cut([-1])); // [9]\n\nvar array1x3 = ee.Array([0, 1, 2]);\nprint(array1x3.cut([-1])); // [0,1,2]\nprint(array1x3.cut([0])); // [0]\nprint(array1x3.cut([2])); // [2]\n\nvar array2x3 = ee.Array([[0, 1, 2], [3, 4, 5]]);\nprint(array2x3.cut([-1, -1])); // [[0,1,2],[3,4,5]]\nprint(array2x3.cut([-1, 0])); // [[0],[3]]\nprint(array2x3.cut([1, -1])); // [[3,4,5]]\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\ndisplay(ee.Array([9]).cut([0])) # [9]\ndisplay(ee.Array([9]).cut([-1])) # [9]\n\narray1x3 = ee.Array([0, 1, 2])\ndisplay(array1x3.cut([-1])) # [0, 1, 2]\ndisplay(array1x3.cut([0])) # [0]\ndisplay(array1x3.cut([2])) # [2]\n\narray2x3 = ee.Array([[0, 1, 2], [3, 4, 5]])\ndisplay(array2x3.cut([-1, -1])) # [[0, 1, 2], [3 , 4, 5]]\ndisplay(array2x3.cut([-1, 0])) # [[0], [3]]\ndisplay(array2x3.cut([1, -1])) # [[3, 4, 5]]\n```"]]