ee.FeatureCollection.map

מיפוי אלגוריתם על אוסף.

הפונקציה מחזירה את האוסף הממופה.

שימושהחזרות
FeatureCollection.map(algorithm, dropNulls)אוסף
ארגומנטסוגפרטים
זה: collectionאוסףמופע האוסף.
algorithmפונקציההפעולה למיפוי התמונות או התכונות של האוסף. פונקציית JavaScript שמקבלת תמונה או תכונות ומחזירה תמונה או תכונות. הפונקציה נקראת רק פעם אחת והתוצאה נשמרת כתיאור, כך שהיא לא יכולה לבצע פעולות אימפרטיביות או להסתמך על מצב חיצוני.
dropNullsבוליאני, אופציונליאם הערך הוא true, לאלגוריתם הממופה מותר להחזיר ערכי null, והרכיבים שעבורם הוא מחזיר ערכי null יושמטו.

דוגמאות

עורך הקוד (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 API ועל שימוש ב-geemap לפיתוח אינטראקטיבי מופיע בדף Python Environment.

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