공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
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())
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003erename()\u003c/code\u003e method allows you to rename keys within an Earth Engine Dictionary object.\u003c/p\u003e\n"],["\u003cp\u003eIt takes two required arguments: \u003ccode\u003efrom\u003c/code\u003e (a list of keys to rename) and \u003ccode\u003eto\u003c/code\u003e (a list of new names corresponding to the \u003ccode\u003efrom\u003c/code\u003e list).\u003c/p\u003e\n"],["\u003cp\u003eThe optional \u003ccode\u003eoverwrite\u003c/code\u003e argument, set to \u003ccode\u003efalse\u003c/code\u003e by default, controls whether existing keys can be overwritten during renaming.\u003c/p\u003e\n"]]],["The content describes how to rename keys within a dictionary using the `Dictionary.rename()` method. This method takes two lists: `from` (keys to be renamed) and `to` (new key names), which must have the same length. The optional `overwrite` parameter (default: `false`) allows replacing existing keys. The function returns the modified dictionary. Examples in JavaScript and Python showcase renaming specific keys and overwriting existing ones.\n"],null,["# ee.Dictionary.rename\n\nRename elements in a dictionary.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------------|------------|\n| Dictionary.rename`(from, to, `*overwrite*`)` | Dictionary |\n\n| Argument | Type | Details |\n|--------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------|\n| this: `dictionary` | Dictionary | |\n| `from` | List | A list of keys to be renamed. |\n| `to` | List | A list of the new names for the keys listed in the 'from' parameter. Must have the same length as the 'from' list. |\n| `overwrite` | Boolean, default: false | Allow overwriting existing properties with the same name. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\nvar dict = ee.Dictionary({\n B1: 182,\n B2: 219,\n B3: 443\n});\n\n// Define from-to key name lists for selected keys.\nvar from = ['B2', 'B3'];\nvar to = ['Band_2', 'Band_3'];\nprint('Renamed keys', dict.rename(from, to));\n\nprint('Overwrite existing key names, e.g. B3 becomes B1',\n dict.rename({from: ['B3'], to: ['B1'], overwrite: true}));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\ndic = ee.Dictionary({\n 'B1': 182,\n 'B2': 219,\n 'B3': 443\n})\n\n# Define from-to key name lists for selected keys.\nfrm = ['B2', 'B3']\nto = ['Band_2', 'Band_3']\nprint('Renamed keys:', dic.rename(frm, to).getInfo())\n\ndic_overwrite = dic.rename(**{'from': ['B3'], 'to': ['B1'], 'overwrite': True})\nprint('Overwrite existing key names, e.g. B3 becomes B1:',\n dic_overwrite.getInfo())\n```"]]