إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ee.Dictionary.combine
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يدمج قاموسَين. في حال تكرار الأسماء، سيحتوي الناتج على قيمة القاموس الثاني ما لم تكن الكتابة فوق البيانات غير مفعّلة. يتم تجاهل القيم الخالية في كلتا القائمتين أو إزالتها.
الاستخدام | المرتجعات |
---|
Dictionary.combine(second, overwrite) | القاموس |
الوسيطة | النوع | التفاصيل |
---|
هذا: first | القاموس | |
second | القاموس | |
overwrite | قيمة منطقية، القيمة التلقائية: true | |
أمثلة
محرّر الرموز البرمجية (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));
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap
للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
import pprint
# 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.
})
print('Combined dictionaries (overwrite false)')
pprint.pprint(dic_1.combine(dic_2, False).getInfo())
print('\nCombined dictionaries (overwrite true)')
pprint.pprint(dic_1.combine(dic_2, True).getInfo())
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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```"]]