Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["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 2023-10-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eDictionary.set\u003c/code\u003e method is used to assign a new value to a specified key within an existing Earth Engine dictionary.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts the dictionary, the key to be updated, and the new value as arguments.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns a new dictionary with the updated key-value pair, leaving the original dictionary unchanged.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is useful for modifying data within Earth Engine dictionaries, like those containing image band values or other geospatial information.\u003c/p\u003e\n"]]],["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"],null,["Set a value in a dictionary.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------|------------|\n| Dictionary.set`(key, value)` | Dictionary |\n\n| Argument | Type | Details |\n|--------------------|------------|---------|\n| this: `dictionary` | Dictionary | |\n| `key` | String | |\n| `value` | Object | |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\nvar dict = ee.Dictionary({\n B1: 182,\n B2: 219,\n B3: 443\n});\n\nprint('Set value for B3 key as -9999', dict.set('B3', -9999));\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\nColab (Python) \n\n```python\n# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).\ndic = ee.Dictionary({\n 'B1': 182,\n 'B2': 219,\n 'B3': 443\n})\n\nprint('Set value for B3 key as -9999:', dic.set('B3', -9999).getInfo())\n```"]]