ee.FeatureCollection.limit

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

傳回受限的集合。

用量傳回
FeatureCollection.limit(max, property, ascending)集合
引數類型詳細資料
這個: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 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

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

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

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

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