AI-generated Key Takeaways
-
This function combines two dictionaries, prioritizing the second dictionary's value for duplicate keys unless
overwriteis set to false. -
Null values present in either dictionary are ignored and excluded from the output.
-
The
combinefunction takes a second dictionary and an optional booleanoverwriteargument and returns a combined Dictionary.
| Usage | Returns |
|---|---|
Dictionary.
combine
(second, overwrite
)
|
Dictionary |
| Argument | Type | Details |
|---|---|---|
|
this:
first
|
Dictionary | |
second
|
Dictionary | |
overwrite
|
Boolean, default: true |
Examples
Code Editor (JavaScript)
// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image). var dict1 = ee . Dictionary ({ B1 : 182 , B2 : 219 , B3 : 443 }); // A second dictionary. var dict2 = ee . Dictionary ({ Region : 'The Forest of Nisene Marks State Park' , Image : 'Sentinel-2 surface reflectance (scaled by 1e4)' , B1 : - 9999 // Note that the B1 key is present in both dictionaries. }); print ( 'Combined dictionaries (overwrite false)' , dict1 . combine ( dict2 , false )); print ( 'Combined dictionaries (overwrite true)' , dict1 . combine ( dict2 , true ));
import ee import geemap.core as geemap
Colab (Python)
# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image). dic_1 = ee . Dictionary ({ 'B1' : 182 , 'B2' : 219 , 'B3' : 443 }) # A second dictionary. dic_2 = ee . Dictionary ({ 'Region' : 'The Forest of Nisene Marks State Park' , 'Image' : 'Sentinel-2 surface reflectance (scaled by 1e4)' , 'B1' : - 9999 # Note that the B1 key is present in both dictionaries. }) display ( 'Combined dictionaries (overwrite false)' , dic_1 . combine ( dic_2 , False )) display ( 'Combined dictionaries (overwrite true)' , dic_1 . combine ( dic_2 , True ))

