ee.FeatureCollection.map

تُستخدَم لربط خوارزمية بمجموعة.

تعرض هذه السمة المجموعة التي تم ربطها.

الاستخدامالمرتجعات
FeatureCollection.map(algorithm, dropNulls)مجموعة
الوسيطةالنوعالتفاصيل
هذا: collectionمجموعةمثيل المجموعة
algorithmالوظيفةالعملية التي سيتم تطبيقها على الصور أو العناصر في المجموعة دالة JavaScript تتلقّى صورة أو ميزات وتعرض صورة أو ميزات. يتم استدعاء الدالة مرة واحدة فقط ويتم تسجيل النتيجة كوصف، لذا لا يمكنها تنفيذ عمليات إلزامية أو الاعتماد على حالة خارجية.
dropNullsقيمة منطقية، اختياريةإذا كانت القيمة صحيحة، يُسمح للخوارزمية التي تم ربطها بعرض قيم فارغة، وسيتم تجاهل العناصر التي تعرض قيمًا فارغة.

أمثلة

محرّر الرموز البرمجية (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');

// Function to convert power plant capacity from megawatts to gigawatts and
// add the value as a new feature property.
var mwToGw = function(feature) {
  var megawatt = feature.getNumber('capacitymw');
  var gigawatt = megawatt.divide(1000);
  return feature.set('capacitygw', gigawatt);
};

// Apply the function to each feature in the collection.
fc = fc.map(mwToGw);

print('Note the new "capacitygw" property in each feature', fc);

إعداد Python

راجِع صفحة بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

# Function to convert power plant capacity from megawatts to gigawatts and
# add the value as a new feature property.
def mw_to_gw(feature):
  megawatt = feature.getNumber('capacitymw')
  gigawatt = megawatt.divide(1000)
  return feature.set('capacitygw', gigawatt)

# Apply the function to each feature in the collection.
fc = fc.map(mw_to_gw)

print('Note the new "capacitygw" property in each feature:', fc.getInfo())