ee.Dictionary

Construit un nouveau dictionnaire.

UtilisationRenvoie
ee.Dictionary(dict)Dictionnaire
ArgumentTypeDétails
dictComputedObject|Object, facultatifObjet à convertir en dictionnaire. Ce constructeur accepte les types suivants : 1) un autre dictionnaire. 2) Une liste de paires clé/valeur. 3) Un argument nul ou inexistant (qui génère un dictionnaire vide)

Exemples

Éditeur de code (JavaScript)

// A dictionary input (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = {
  B1: 182,
  B2: 219,
  B3: 443
};
print('ee.Dictionary from dictionary input', ee.Dictionary(dict));

// A list of key/value pairs (from previous dictionary).
var list = [
  'B1', 182,
  'B2', 219,
  'B3', 443
];
print('ee.Dictionary from list input', ee.Dictionary(list));

// To create an ee.Dictionary from two corresponding lists of keys and values,
// use the ee.Dictionary.fromLists constructor.
var keys = ['B1', 'B2', 'B3'];
var values = [182, 219, 443];
print('Dictionary from lists of keys and values',
      ee.Dictionary.fromLists(keys, values));

Configuration de Python

Consultez la page Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary input (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = {
    'B1': 182,
    'B2': 219,
    'B3': 443
}
print('ee.Dictionary from dictionary input:', ee.Dictionary(dic).getInfo())

# A list of key/value pairs (from previous dictionary).
lst = [
    'B1', 182,
    'B2', 219,
    'B3', 443
]
print('ee.Dictionary from list input', ee.Dictionary(lst).getInfo())