ee.FeatureCollection.limit

將集合限制為指定數量的元素,並可選擇先依指定屬性排序。

傳回受限集合。

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

範例

程式碼編輯器 (JavaScript)

// FeatureCollection of global power plants.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants');

print('First 5 features (power plants)', fc.limit(5));

print('Smallest 5 power plants by capacity in ascending order',
      fc.limit({max: 5, property: 'capacitymw'}));

print('Largest 5 power plants by capacity in descending order',
      fc.limit({max: 5, property: 'capacitymw', ascending: false}));

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection of global power plants.
fc = ee.FeatureCollection('WRI/GPPD/power_plants')

display('First 5 features (power plants):', fc.limit(5))

display('Smallest 5 power plants by capacity in ascending order:',
        fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw'}))

display('Largest 5 power plants by capacity in descending order:',
        fc.limit(**{'maximum': 5, 'opt_property': 'capacitymw',
                    'opt_ascending': False}))