ee.FeatureCollection.map

Aplica un algoritmo a una colección.

Devuelve la colección asignada.

UsoMuestra
FeatureCollection.map(algorithm, dropNulls)Colección
ArgumentoTipoDetalles
esta: collectionColecciónInstancia de Collection.
algorithmFunciónOperación para asignar a las imágenes o características de la colección. Es una función de JavaScript que recibe una imagen o características y devuelve una. La función se llama solo una vez y el resultado se captura como una descripción, por lo que no puede realizar operaciones imperativas ni depender de un estado externo.
dropNullsBooleano, opcionalSi es verdadero, se permite que el algoritmo asignado devuelva valores nulos, y se descartarán los elementos para los que devuelva valores nulos.

Ejemplos

Editor de código (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);

Configuración de Python

Consulta la página Entorno de Python para obtener información sobre la API de Python y el uso de geemap para el desarrollo interactivo.

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