Earth Engine telah memperkenalkan
tingkat kuota nonkomersial untuk melindungi resource komputasi bersama dan memastikan performa yang andal bagi semua orang. Project nonkomersial menggunakan Tingkat Komunitas secara default, meskipun Anda dapat mengubah tingkat project kapan saja.
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.Dictionary.get
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mengekstrak nilai bernama dari kamus. Jika kamus tidak berisi kunci yang diberikan, defaultValue akan ditampilkan, kecuali jika null.
| Penggunaan | Hasil |
|---|
Dictionary.get(key, defaultValue) | Objek |
| Argumen | Jenis | Detail |
|---|
ini: dictionary | Kamus | |
key | String | |
defaultValue | Objek, default: null | |
Contoh
Code Editor (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}));
Penyiapan Python
Lihat halaman
Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan
geemap untuk pengembangan interaktif.
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
})
display('Value for "B1" key:', dic.get('B1'))
# Set a default value for the case where the key does not exist.
display('Value for nonexistent "Band_1" key:',
dic.get(**{'key': 'Band_1', 'defaultValue': -9999}))
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-10-30 UTC.
[null,null,["Terakhir diperbarui pada 2025-10-30 UTC."],[],["The `get` method retrieves a value from a dictionary using a specified key. If the key exists, its corresponding value is returned. If the key is absent, a `defaultValue` is returned. The `defaultValue` can be customized, defaulting to `null` if not provided. Usage examples demonstrate retrieving existing values and setting default values for nonexistent keys, in both JavaScript and Python. The `get` method is applicable to dictionary objects.\n"]]