ee.FeatureCollection.makeArray

將每個特徵的屬性清單合併為一維陣列,然後將一維陣列新增至集合中的每個特徵。所有屬性都必須是數值。如果特徵未包含所有具名屬性,或任何屬性不是數值,系統就會從產生的集合中捨棄該特徵。

用量傳回
FeatureCollection.makeArray(properties, name)FeatureCollection
引數類型詳細資料
這個:collectionFeatureCollection要從中選取屬性的輸入集合。
properties清單要選取的屬性。
name字串,預設值為「array」新陣列屬性的名稱。

範例

程式碼編輯器 (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');

// A list of feature properties to combine into an array
// (power generation by year).
var properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016'];

// Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year');

print('FeatureCollection with array of selected properties added', fc);
print('See example of new "gwh_by_year" property', fc.first().toDictionary());

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

from pprint import pprint

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

# A list of feature properties to combine into an array
# (power generation by year).
properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016']

# Add array of power-generation-by-year property to features.
fc = fc.makeArray(properties, 'gwh_by_year')

print('FeatureCollection with array of selected properties added:',
      fc.getInfo())
print('See example of new "gwh_by_year" property:')
pprint(fc.first().toDictionary().getInfo())