Announcement : On
November 13, 2024 , all users will need to
use a Cloud project in order to access Earth Engine. After this date, continued individual access without a Cloud project will require
an exception .
Send feedback
ee.List.splice
Stay organized with collections
Save and categorize content based on your preferences.
Starting at the start index, removes count elements from list and insert the contents of other at that location. If start is negative, it counts backwards from the end of the list.
Usage Returns List. splice (start, count, other )
List
Argument Type Details this: list
List start
Integer count
Integer other
List, default: null
Examples
Code Editor (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 2n d 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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
# An ee.List object.
ee_list = ee . List ([ 0 , 1 , 2 , 3 , 4 ])
print ( 'Original list :', ee_list . getInfo ())
# If "other" argument is None, elements at positions specified by "start" and
# "count" are deleted. Here, the 3rd element is removed.
print ( 'Remove 1 element :',
ee_list . splice ( start = 2 , count = 1 , other = None ) . getInfo ())
# If "start" is negative, the position is from the end of the list.
print ( 'Remove 2 nd from last element :', ee_list . splice ( - 2 , 1 ) . getInfo ())
# Deletes 3 elements starting at position 1.
print ( 'Remove multiple sequential elements :', ee_list . splice ( 1 , 3 ) . getInfo ())
# 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 :', ee_list . splice ( 2 , 0 , [ 'X ', 'Y ', 'Z ']) . getInfo ())
# 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 :', ee_list . splice ( 2 , 3 , [ 'X ', 'Y ', 'Z ']) . getInfo ())
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-05 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-06-05 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-05 UTC."]]