ee.Dictionary.combine

รวมพจนานุกรม 2 เล่ม ในกรณีที่มีชื่อซ้ำ เอาต์พุตจะมีค่าของพจนานุกรมที่ 2 เว้นแต่จะตั้งค่า "เขียนทับ" เป็น false ระบบจะไม่สนใจ / นำค่า Null ในทั้ง 2 พจนานุกรมออก

การใช้งานการคืนสินค้า
Dictionary.combine(second, overwrite)พจนานุกรม
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ firstพจนานุกรม
secondพจนานุกรม
overwriteบูลีน ค่าเริ่มต้น: จริง

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (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 API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

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())