ee.FeatureCollection.map

Memetakan algoritma ke seluruh koleksi.

Menampilkan koleksi yang dipetakan.

PenggunaanHasil
FeatureCollection.map(algorithm, dropNulls)Koleksi
ArgumenJenisDetail
ini: collectionKoleksiInstance Koleksi.
algorithmFungsiOperasi untuk memetakan gambar atau fitur koleksi. Fungsi JavaScript yang menerima gambar atau fitur dan menampilkan satu gambar atau fitur. Fungsi hanya dipanggil satu kali dan hasilnya diambil sebagai deskripsi, sehingga tidak dapat melakukan operasi imperatif atau mengandalkan status eksternal.
dropNullsBoolean, opsionalJika benar (true), algoritma yang dipetakan diizinkan untuk menampilkan nilai null, dan elemen yang menampilkan nilai null akan dihilangkan.

Contoh

Code Editor (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);

Penyiapan Python

Lihat halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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