ee.FeatureCollection.map

Ordnet einer Sammlung einen Algorithmus zu.

Gibt die zugeordnete Sammlung zurück.

NutzungAusgabe
FeatureCollection.map(algorithm, dropNulls)Sammlung
ArgumentTypDetails
Dieses: collectionSammlungDie Sammlungsinstanz.
algorithmFunktionDer Vorgang, der auf die Bilder oder Features der Sammlung angewendet werden soll. Eine JavaScript-Funktion, die ein Bild oder Feature empfängt und 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 kein externer Status verwendet werden.
dropNullsBoolesch, optionalWenn „true“, darf der zugeordnete Algorithmus Nullwerte zurückgeben. Die Elemente, für die Nullwerte zurückgegeben werden, 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

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

display('Note the new "capacitygw" property in each feature:', fc)