AI-generated Key Takeaways
-
The
ee.Dictionary()constructor creates a new Dictionary in Earth Engine. -
It accepts a dictionary, a list of key/value pairs, or no arguments (for an empty dictionary).
-
Examples are provided for creating
ee.Dictionaryfrom various inputs in both JavaScript and Python.
| Usage | Returns |
|---|---|
ee.Dictionary( dict
)
|
Dictionary |
| Argument | Type | Details |
|---|---|---|
dict
|
ComputedObject|Object, optional | An object to convert to a dictionary. This constructor accepts the following types: 1) Another dictionary. 2) A list of key/value pairs. 3) A null or no argument (producing an empty dictionary) |
Examples
Code Editor (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 ));
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 } display ( 'ee.Dictionary from dictionary input:' , ee . Dictionary ( dic )) # A list of key/value pairs (from previous dictionary). lst = [ 'B1' , 182 , 'B2' , 219 , 'B3' , 443 ] display ( 'ee.Dictionary from list input' , ee . Dictionary ( lst ))

