ee.FeatureCollection.map

Mapeia um algoritmo em uma coleção.

Retorna a coleção mapeada.

UsoRetorna
FeatureCollection.map(algorithm, dropNulls)Coleção
ArgumentoTipoDetalhes
isso: collectionColeçãoA instância da coleção.
algorithmFunçãoA operação para mapear as imagens ou recursos da coleção. Uma função JavaScript que recebe uma imagem ou recursos e retorna um deles. A função é chamada apenas uma vez, e o resultado é capturado como uma descrição. Portanto, ela não pode realizar operações imperativas nem depender de um estado externo.
dropNullsBooleano, opcionalSe for verdadeiro, o algoritmo mapeado poderá retornar valores nulos, e os elementos para os quais ele retorna valores nulos serão descartados.

Exemplos

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

Configuração do Python

Consulte a página Ambiente Python para informações sobre a API Python e como usar geemap para desenvolvimento interativo.

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