ee.Dictionary.rename

تغییر نام عناصر در فرهنگ لغت

استفاده برمی گرداند
Dictionary. rename (from, to, overwrite ) فرهنگ لغت
استدلال تایپ کنید جزئیات
این: dictionary فرهنگ لغت
from فهرست کنید لیستی از کلیدهایی که باید تغییر نام دهند.
to فهرست کنید فهرستی از نام‌های جدید کلیدهای فهرست شده در پارامتر «از». باید طولی برابر با لیست «از» داشته باشد.
overwrite بولی، پیش فرض: نادرست اجازه رونویسی خصوصیات موجود با همان نام را بدهید.

نمونه ها

ویرایشگر کد (جاوا اسکریپت)

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

راه اندازی پایتون

برای اطلاعات در مورد API پایتون و استفاده از geemap برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.

import ee
import geemap.core as geemap

کولب (پایتون)

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