ee.List.get
Stay organized with collections
Save and categorize content based on your preferences.
Returns the element at the specified position in list. A negative index counts backwards from the end of the list.
Usage | Returns | List.get(index) | Object |
Argument | Type | Details | this: list | List | |
index | Integer | |
Examples
Code Editor (JavaScript)
// An ee.List object.
var list = ee.List([5, 10, 15, 20, 25, 30]);
// Fetch elements at specified 0-based positions in the list.
print('The second element', list.get(1));
print('The fourth element', list.get(3));
print('The last element', list.get(-1));
print('The second to last element', list.get(-2));
// ee.Number and integer computed objects are valid inputs.
print('Computed object index input', list.get(list.get(0)));
// The result of ee.List.get is an ambiguous object type. You need to cast the
// result to the expected type to use it in subsequent instance methods. For
// example, if you are fetching a number and wish to add it to another number,
// you must cast the .get() result as an ee.Number.
print('Add fetched number to another number', ee.Number(list.get(1)).add(2));
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([5, 10, 15, 20, 25, 30])
# Fetch elements at specified 0-based positions in the list.
print('The second element:', ee_list.get(1).getInfo())
print('The fourth element:', ee_list.get(3).getInfo())
print('The last element:', ee_list.get(-1).getInfo())
print('The second to last element:', ee_list.get(-2).getInfo())
# ee.Number and integer computed objects are valid inputs.
print('Computed object index input:', ee_list.get(list.get(0)).getInfo())
# The result of ee.List.get is an ambiguous object type. You need to cast the
# result to the expected type to use it in subsequent instance methods. For
# example, if you are fetching a number and wish to add it to another number,
# you must cast the .get() result as an ee.Number.
print('Add fetched number to another number:',
ee.Number(list.get(1)).add(2).getInfo())
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 2023-10-06 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"
}]