ee.FeatureCollection.map

Wendet einen Algorithmus auf eine Sammlung an.

Gibt die zugeordnete Sammlung zurück.

NutzungAusgabe
FeatureCollection.map(algorithm, dropNulls)Sammlung
ArgumentTypDetails
So gehts: collectionSammlungDie Sammlung.
algorithmFunktionDer Vorgang, der auf die Bilder oder Funktionen der Sammlung angewendet werden soll. Eine JavaScript-Funktion, die ein Bild oder Features empfängt und eines zurückgibt. Die Funktion wird nur einmal aufgerufen und das Ergebnis wird als Beschreibung erfasst. Daher können keine imperativen Vorgänge ausgeführt werden und es kann nicht auf den externen Status zurückgegriffen werden.
dropNullsBoolesch, optionalWenn „true“, darf der zugeordnete Algorithmus Nullwerte zurückgeben. Die Elemente, für die er Nullwerte zurückgibt, werden verworfen.

Beispiele

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

Python einrichten

Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung finden Sie auf der Seite Python-Umgebung.

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