ee.FeatureCollection.map

Карты алгоритма над коллекцией.

Возвращает картированную коллекцию.

Использование Возврат
FeatureCollection. map (algorithm, dropNulls ) Коллекция
Аргумент Тип Подробности
это: collection Коллекция Экземпляр коллекции.
algorithm Функция Операция сопоставления изображений или объектов коллекции. Функция JavaScript, которая получает изображение или объекты и возвращает их. Функция вызывается только один раз, а результат сохраняется в виде описания, поэтому она не может выполнять императивные операции или полагаться на внешнее состояние.
dropNulls Булевое значение, необязательное Если значение равно true, сопоставленному алгоритму разрешено возвращать значения NULL, а элементы, для которых он возвращает значения NULL, будут отброшены.

Примеры

Редактор кода (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

Информацию об API Python и использовании geemap для интерактивной разработки см. на странице «Среда Python» .

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