ee.Dictionary.get

사전에서 이름이 지정된 값을 추출합니다. 사전에 지정된 키가 포함되어 있지 않으면 defaultValue가 반환됩니다(null이 아닌 경우).

사용반환 값
Dictionary.get(key, defaultValue)객체
인수유형세부정보
다음과 같은 경우: dictionary딕셔너리
key문자열
defaultValue객체, 기본값: null

코드 편집기 (JavaScript)

// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

print('Value for "B1" key', dict.get('B1'));

// Set a default value for the case where the key does not exist.
print('Value for nonexistent "Band_1" key',
      dict.get({key: 'Band_1', defaultValue: -9999}));

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

print('Value for "B1" key:', dic.get('B1').getInfo())

# Set a default value for the case where the key does not exist.
print('Value for nonexistent "Band_1" key:',
      dic.get(**{'key': 'Band_1', 'defaultValue': -9999}).getInfo())