ee.FeatureCollection.map

แมปอัลกอริทึมกับคอลเล็กชัน

แสดงผลคอลเล็กชันที่แมป

การใช้งานการคืนสินค้า
FeatureCollection.map(algorithm, dropNulls)คอลเล็กชัน
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ collectionคอลเล็กชันอินสแตนซ์คอลเล็กชัน
algorithmฟังก์ชันการดำเนินการเพื่อแมปรูปภาพหรือฟีเจอร์ของคอลเล็กชัน ฟังก์ชัน JavaScript ที่รับรูปภาพหรือฟีเจอร์และแสดงผลรูปภาพหรือฟีเจอร์ ระบบจะเรียกใช้ฟังก์ชันเพียงครั้งเดียวและบันทึกผลลัพธ์เป็นคำอธิบาย จึงไม่สามารถดำเนินการที่จำเป็นหรืออาศัยสถานะภายนอกได้
dropNullsบูลีน ไม่บังคับหากเป็นจริง อัลกอริทึมที่แมปจะได้รับอนุญาตให้แสดงผลค่า 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

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