ee.List.get

목록에서 지정된 위치의 요소를 반환합니다. 음수 색인은 목록의 끝에서부터 역순으로 계산됩니다.

사용반환 값
List.get(index)객체
인수유형세부정보
다음과 같은 경우: list목록
index정수

코드 편집기 (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 설정

Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 Python 환경 페이지를 참고하세요.

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())