Send feedback
ee.Dictionary
Stay organized with collections
Save and categorize content based on your preferences.
Constructs a new Dictionary.
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));
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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())
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?