ee.Dictionary.map

แมปอัลกอริทึมกับพจนานุกรม อัลกอริทึมควรรับอาร์กิวเมนต์ 2 รายการ ได้แก่ คีย์จากพจนานุกรมที่มีอยู่และค่าที่สอดคล้องกัน แล้วส่งคืนค่าใหม่สำหรับคีย์ที่ระบุ หากอัลกอริทึมแสดงผลเป็น Null ระบบจะทิ้งคีย์

การใช้งานการคืนสินค้า
Dictionary.map(baseAlgorithm)พจนานุกรม
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ dictionaryพจนานุกรม
baseAlgorithmอัลกอริทึม

ตัวอย่าง

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

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

/**
 * Convert S2 surface reflectance units to native scale.
 */
function scale(key, value) {
  return ee.Number(value).divide(1e4);
}

print('S2 surface reflectance in native units', dict.map(scale));

การตั้งค่า Python

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

import ee
import geemap.core as geemap

Colab (Python)

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


def scale(key, value):
  """Convert S2 surface reflectance units to native scale."""
  return ee.Number(value).divide(1e4)

print('S2 surface reflectance in native units:', dic.map(scale).getInfo())