ee.Dictionary

Tạo một Từ điển mới.

Cách sử dụngGiá trị trả về
ee.Dictionary(dict)Từ điển
Đối sốLoạiThông tin chi tiết
dictComputedObject|Object, không bắt buộcMột đối tượng cần chuyển đổi thành từ điển. Hàm khởi tạo này chấp nhận các loại sau: 1) Một từ điển khác. 2) Danh sách các cặp khoá/giá trị. 3) Một đối số rỗng hoặc không có đối số (tạo ra một từ điển trống)

Ví dụ

Trình soạn thảo mã (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));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

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