ee.Dictionary.get

किसी डिक्शनरी से, नाम वाली वैल्यू निकालता है. अगर डिक्शनरी में दी गई कुंजी मौजूद नहीं है, तो defaultValue दिखता है. हालांकि, अगर यह शून्य है, तो ऐसा नहीं होगा.

इस्तेमालरिटर्न
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())