ee.FeatureCollection.map

Mappe un algorithme sur une collection.

Renvoie la collection mappée.

UtilisationRenvoie
FeatureCollection.map(algorithm, dropNulls)Collection
ArgumentTypeDétails
ceci : collectionCollectionInstance de la collection.
algorithmFonctionOpération à mapper sur les images ou les caractéristiques de la collection. Fonction JavaScript qui reçoit une image ou des caractéristiques et en renvoie une. La fonction n'est appelée qu'une seule fois et le résultat est capturé sous forme de description. Elle ne peut donc pas effectuer d'opérations impératives ni s'appuyer sur un état externe.
dropNullsBooléen, facultatifSi la valeur est "true", l'algorithme mappé est autorisé à renvoyer des valeurs nulles, et les éléments pour lesquels il renvoie des valeurs nulles seront supprimés.

Exemples

Éditeur de code (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);

Configuration de Python

Consultez la page Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.

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