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