お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ee.FeatureCollection.map
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
コレクションにアルゴリズムをマッピングします。
マッピングされたコレクションを返します。
用途 | 戻り値 |
---|
FeatureCollection.map(algorithm, dropNulls) | コレクション |
引数 | タイプ | 詳細 |
---|
これ: collection | コレクション | Collection インスタンス。 |
algorithm | 関数 | コレクションの画像または特徴をマッピングするオペレーション。画像または特徴を受け取り、1 つを返す JavaScript 関数。この関数は 1 回だけ呼び出され、結果は説明としてキャプチャされるため、命令型オペレーションを実行したり、外部状態に依存したりすることはできません。 |
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 の設定
Python API とインタラクティブな開発での 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())
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 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```"]]