ee.Dictionary

สร้างพจนานุกรมใหม่

การใช้งานการคืนสินค้า
ee.Dictionary(dict)พจนานุกรม
อาร์กิวเมนต์ประเภทรายละเอียด
dictComputedObject|Object, ไม่บังคับออบเจ็กต์ที่จะแปลงเป็นพจนานุกรม ตัวสร้างนี้ยอมรับประเภทต่อไปนี้ 1) พจนานุกรมอื่น 2) รายการคู่คีย์/ค่า 3) ไม่มีอาร์กิวเมนต์หรืออาร์กิวเมนต์เป็น Null (สร้างพจนานุกรมว่างเปล่า)

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

// A dictionary input (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = {
  B1: 182,
  B2: 219,
  B3: 443
};
print('ee.Dictionary from dictionary input', ee.Dictionary(dict));

// A list of key/value pairs (from previous dictionary).
var list = [
  'B1', 182,
  'B2', 219,
  'B3', 443
];
print('ee.Dictionary from list input', ee.Dictionary(list));

// To create an ee.Dictionary from two corresponding lists of keys and values,
// use the ee.Dictionary.fromLists constructor.
var keys = ['B1', 'B2', 'B3'];
var values = [182, 219, 443];
print('Dictionary from lists of keys and values',
      ee.Dictionary.fromLists(keys, values));

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary input (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = {
    'B1': 182,
    'B2': 219,
    'B3': 443
}
print('ee.Dictionary from dictionary input:', ee.Dictionary(dic).getInfo())

# A list of key/value pairs (from previous dictionary).
lst = [
    'B1', 182,
    'B2', 219,
    'B3', 443
]
print('ee.Dictionary from list input', ee.Dictionary(lst).getInfo())