Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Stay organized with collections
Save and categorize content based on your preferences.
Maps an algorithm over a collection.
Returns the mapped collection.
Usage
Returns
FeatureCollection.map(algorithm, dropNulls)
Collection
Argument
Type
Details
this: collection
Collection
The Collection instance.
algorithm
Function
The 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.
dropNulls
Boolean, optional
If true, the mapped algorithm is allowed to return nulls, and the elements for which it returns nulls will be dropped.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003e\u003ccode\u003emap()\u003c/code\u003e iterates over a FeatureCollection, applying a user-defined function to each feature.\u003c/p\u003e\n"],["\u003cp\u003eThe provided function transforms features and returns modified versions, creating a new FeatureCollection.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003emap()\u003c/code\u003e allows adding/modifying properties of features within a FeatureCollection or performing calculations based on existing properties.\u003c/p\u003e\n"],["\u003cp\u003eAn optional \u003ccode\u003edropNulls\u003c/code\u003e parameter controls whether features resulting in null from the mapping function are retained in the output.\u003c/p\u003e\n"]]],["The `map` algorithm applies a user-defined function to each element within a collection (e.g., features or images). This function, which accepts an element as input and returns a modified one, is applied to each item of the collection. The `dropNulls` argument allows filtering null return values. The result is a new collection containing the modified elements. For example, converting power plant capacity units and adding them as a new property to the features.\n"],null,["# ee.FeatureCollection.map\n\n\u003cbr /\u003e\n\nMaps an algorithm over a collection.\n\n\u003cbr /\u003e\n\nReturns the mapped collection.\n\n| Usage | Returns |\n|---------------------------------------------------|------------|\n| FeatureCollection.map`(algorithm, `*dropNulls*`)` | Collection |\n\n| Argument | Type | Details |\n|--------------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `collection` | Collection | The Collection instance. |\n| `algorithm` | Function | The 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. |\n| `dropNulls` | Boolean, optional | If true, the mapped algorithm is allowed to return nulls, and the elements for which it returns nulls will be dropped. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// FeatureCollection of power plants in Belgium.\nvar fc = ee.FeatureCollection('WRI/GPPD/power_plants')\n .filter('country_lg == \"Belgium\"');\n\n// Function to convert power plant capacity from megawatts to gigawatts and\n// add the value as a new feature property.\nvar mwToGw = function(feature) {\n var megawatt = feature.getNumber('capacitymw');\n var gigawatt = megawatt.divide(1000);\n return feature.set('capacitygw', gigawatt);\n};\n\n// Apply the function to each feature in the collection.\nfc = fc.map(mwToGw);\n\nprint('Note the new \"capacitygw\" property in each feature', fc);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# FeatureCollection of power plants in Belgium.\nfc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(\n 'country_lg == \"Belgium\"')\n\n# Function to convert power plant capacity from megawatts to gigawatts and\n# add the value as a new feature property.\ndef mw_to_gw(feature):\n megawatt = feature.getNumber('capacitymw')\n gigawatt = megawatt.divide(1000)\n return feature.set('capacitygw', gigawatt)\n\n# Apply the function to each feature in the collection.\nfc = fc.map(mw_to_gw)\n\nprint('Note the new \"capacitygw\" property in each feature:', fc.getInfo())\n```"]]