Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Stay organized with collections
Save and categorize content based on your preferences.
Combines two dictionaries. In the case of duplicate names, the output will contain the value of the second dictionary unless overwrite is false. Null values in both dictionaries are ignored / removed.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-13 UTC."],[[["\u003cp\u003e\u003ccode\u003eDictionary.combine()\u003c/code\u003e merges two dictionaries into a single dictionary.\u003c/p\u003e\n"],["\u003cp\u003eIf the same key exists in both dictionaries, the value from the second dictionary is used by default, unless \u003ccode\u003eoverwrite\u003c/code\u003e is set to \u003ccode\u003efalse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eNull values present in either of the input dictionaries are automatically excluded from the final combined dictionary.\u003c/p\u003e\n"],["\u003cp\u003eIt's accessible in both JavaScript and Python environments within the Earth Engine platform.\u003c/p\u003e\n"]]],[],null,["# ee.Dictionary.combine\n\nCombines two dictionaries. In the case of duplicate names, the output will contain the value of the second dictionary unless overwrite is false. Null values in both dictionaries are ignored / removed.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------|------------|\n| Dictionary.combine`(second, `*overwrite*`)` | Dictionary |\n\n| Argument | Type | Details |\n|---------------|------------------------|---------|\n| this: `first` | Dictionary | |\n| `second` | Dictionary | |\n| `overwrite` | Boolean, default: true | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\nvar dict1 = ee.Dictionary({\n B1: 182,\n B2: 219,\n B3: 443\n});\n\n// A second dictionary.\nvar dict2 = ee.Dictionary({\n Region: 'The Forest of Nisene Marks State Park',\n Image: 'Sentinel-2 surface reflectance (scaled by 1e4)',\n B1: -9999 // Note that the B1 key is present in both dictionaries.\n});\n\nprint('Combined dictionaries (overwrite false)',\n dict1.combine(dict2, false));\n\nprint('Combined dictionaries (overwrite true)',\n dict1.combine(dict2, true));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nimport pprint\n\n# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\ndic_1 = ee.Dictionary({\n 'B1': 182,\n 'B2': 219,\n 'B3': 443\n})\n\n# A second dictionary.\ndic_2 = ee.Dictionary({\n 'Region': 'The Forest of Nisene Marks State Park',\n 'Image': 'Sentinel-2 surface reflectance (scaled by 1e4)',\n 'B1': -9999 # Note that the B1 key is present in both dictionaries.\n})\n\nprint('Combined dictionaries (overwrite false)')\npprint.pprint(dic_1.combine(dic_2, False).getInfo())\n\nprint('\\nCombined dictionaries (overwrite true)')\npprint.pprint(dic_1.combine(dic_2, True).getInfo())\n```"]]