ee.Dictionary.rename

사전의 요소 이름을 바꿉니다.

사용반환 값
Dictionary.rename(from, to, overwrite)딕셔너리
인수유형세부정보
다음과 같은 경우: dictionary딕셔너리
from목록이름을 바꿀 키 목록입니다.
to목록'from' 매개변수에 나열된 키의 새 이름 목록입니다. 'from' 목록과 길이가 같아야 합니다.
overwrite불리언, 기본값: false이름이 같은 기존 속성을 덮어쓰도록 허용

코드 편집기 (JavaScript)

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

// Define from-to key name lists for selected keys.
var from = ['B2', 'B3'];
var to = ['Band_2', 'Band_3'];
print('Renamed keys', dict.rename(from, to));

print('Overwrite existing key names, e.g. B3 becomes B1',
      dict.rename({from: ['B3'], to: ['B1'], overwrite: true}));

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

# Define from-to key name lists for selected keys.
frm = ['B2', 'B3']
to = ['Band_2', 'Band_3']
print('Renamed keys:', dic.rename(frm, to).getInfo())

dic_overwrite = dic.rename(**{'from': ['B3'], 'to': ['B1'], 'overwrite': True})
print('Overwrite existing key names, e.g. B3 becomes B1:',
      dic_overwrite.getInfo())