ee.Dictionary.map

ربط خوارزمية بقاموس من المتوقّع أن تأخذ الخوارزمية وسيطتَين، وهما مفتاح من القاموس الحالي والقيمة التي يتوافق معها، وأن تعرض قيمة جديدة للمفتاح المحدّد. إذا عرضت الخوارزمية قيمة فارغة، يتم تجاهل المفتاح.

الاستخدامالمرتجعات
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 للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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