ee.FeatureCollection.sort

按照指定屬性排序集合。

傳回排序後的集合。

用量傳回
FeatureCollection.sort(property, ascending)集合
引數類型詳細資料
這個:collection集合Collection 執行個體。
property字串要排序的屬性。
ascending布林值 (選填)指定要依遞增或遞減順序排序。預設值為 true (遞增)。

範例

程式碼編輯器 (JavaScript)

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

print('Belgium power plants in ascending order by capacity',
      fc.sort('capacitymw'));

print('Belgium power plants in descending order by capacity',
      fc.sort('capacitymw', false));

Python 設定

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

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"')

print('Belgium power plants in ascending order by capacity:',
      fc.sort('capacitymw').getInfo())

print('Belgium power plants in descending order by capacity:',
      fc.sort('capacitymw', False).getInfo())