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