Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.FeatureCollection.map

  • Themap function applies an algorithm to each element of a collection.

  • It returns a new collection containing the results of the algorithm applied to each original element.

  • An optional argumentdropNulls allows for removing elements where the algorithm returns null.

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.varfc=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.varmwToGw=function(feature){varmegawatt=feature.getNumber('capacitymw');vargigawatt=megawatt.divide(1000);returnfeature.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 setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

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.defmw_to_gw(feature):megawatt=feature.getNumber('capacitymw')gigawatt=megawatt.divide(1000)returnfeature.set('capacitygw',gigawatt)# Apply the function to each feature in the collection.fc=fc.map(mw_to_gw)display('Note the new "capacitygw" property in each feature:',fc)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.