ee.Dictionary.set
Set a value in a dictionary.
Usage | Returns |
---|
Dictionary.set(key, value) | Dictionary |
Argument | Type | Details |
---|
this: dictionary | Dictionary | |
key | String | |
value | Object | |
Examples
// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
B1: 182,
B2: 219,
B3: 443
});
print('Set value for B3 key as -9999', dict.set('B3', -9999));
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
# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
'B1': 182,
'B2': 219,
'B3': 443
})
print('Set value for B3 key as -9999:', dic.set('B3', -9999).getInfo())
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.
[null,null,["Last updated 2023-10-06 UTC."],[[["The `Dictionary.set` method is used to assign a new value to a specified key within an existing Earth Engine dictionary."],["It accepts the dictionary, the key to be updated, and the new value as arguments."],["The method returns a new dictionary with the updated key-value pair, leaving the original dictionary unchanged."],["This functionality is useful for modifying data within Earth Engine dictionaries, like those containing image band values or other geospatial information."]]],["The `Dictionary.set(key, value)` method modifies a dictionary by assigning a new value to a specified key. It takes a dictionary, a string `key`, and an `object` value as arguments, and returns the modified dictionary. The examples demonstrate setting the value of the 'B3' key to -9999 within dictionaries, using both JavaScript and Python. The key should be a String, and the value can be any object.\n"]]