ee.FeatureCollection.map

Stay organized with collections Save and categorize content based on your preferences.

Maps an algorithm over a collection.

Returns the mapped collection.

UsageReturns
FeatureCollection.map(algorithm, dropNulls)Collection
ArgumentTypeDetails
this: collectionCollectionThe Collection instance.
algorithmFunctionThe operation to map over the images or features of the collection. A JavaScript function that receives an image or features and returns one. The function is called only once and the result is captured as a description, so it cannot perform imperative operations or rely on external state.
dropNullsBoolean, optionalIf true, the mapped algorithm is allowed to return nulls, and the elements for which it returns nulls will be dropped.

Examples

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