Earth Engine 将推出
非商业配额层级,以保护共享计算资源并确保为所有人提供可靠的性能。所有非商业项目都需要在
2026 年 4 月 27 日之前选择配额层级,否则系统会默认使用 Community 层级。层级配额将于
2026 年 4 月 27 日对所有项目生效(无论层级选择日期如何)。
了解详情。
ee.List.splice
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从起始索引开始,从列表中移除指定数量的元素,并将其他列表的内容插入到该位置。如果 start 为负数,则从列表末尾开始反向计数。
| 用法 | 返回 |
|---|
List.splice(start, count, other) | 列表 |
| 参数 | 类型 | 详细信息 |
|---|
此:list | 列表 | |
start | 整数 | |
count | 整数 | |
other | 列表,默认值:null | |
示例
代码编辑器 (JavaScript)
// An ee.List object.
var list = ee.List([0, 1, 2, 3, 4]);
print('Original list', list);
// If "other" argument is null, elements at positions specified by "start" and
// "count" are deleted. Here, the 3rd element is removed.
print('Remove 1 element', list.splice({start: 2, count: 1, other: null}));
// If "start" is negative, the position is from the end of the list.
print('Remove 2nd from last element', list.splice(-2, 1));
// Deletes 3 elements starting at position 1.
print('Remove multiple sequential elements', list.splice(1, 3));
// Insert elements from the "other" list without deleting existing elements
// by specifying the insert "start" position and setting "count" to 0.
print('Insert new elements', list.splice(2, 0, ['X', 'Y', 'Z']));
// Replace existing elements with those from the "other" list by specifying the
// "start" position to replace and the "count" of proceeding elements. If
// length of "other" list is greater than "count", the remaining "other"
// elements are inserted, they do not replace existing elements.
print('Replace elements', list.splice(2, 3, ['X', 'Y', 'Z']));
Python 设置
如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# An ee.List object.
ee_list = ee.List([0, 1, 2, 3, 4])
display('Original list:', ee_list)
# If "other" argument is None, elements at positions specified by "start" and
# "count" are deleted. Here, the 3rd element is removed.
display('Remove 1 element:',
ee_list.splice(start=2, count=1, other=None))
# If "start" is negative, the position is from the end of the list.
display('Remove 2nd from last element:', ee_list.splice(-2, 1))
# Deletes 3 elements starting at position 1.
display('Remove multiple sequential elements:', ee_list.splice(1, 3))
# Insert elements from the "other" list without deleting existing elements
# by specifying the insert "start" position and setting "count" to 0.
display('Insert new elements:', ee_list.splice(2, 0, ['X', 'Y', 'Z']))
# Replace existing elements with those from the "other" list by specifying the
# "start" position to replace and the "count" of proceeding elements. If
# length of "other" list is greater than "count", the remaining "other"
# elements are inserted, they do not replace existing elements.
display('Replace elements:', ee_list.splice(2, 3, ['X', 'Y', 'Z']))
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-10-30。
[null,null,["最后更新时间 (UTC):2025-10-30。"],[],[]]