ee.FeatureCollection.limit

Giới hạn một tập hợp theo số lượng phần tử được chỉ định, có thể sắp xếp các phần tử đó theo một thuộc tính được chỉ định trước.

Trả về tập hợp bị giới hạn.

Cách sử dụngGiá trị trả về
FeatureCollection.limit(max, property, ascending)Bộ sưu tập
Đối sốLoạiChi tiết
this: collectionBộ sưu tậpThực thể Collection.
maxSốSố lượng để giới hạn tập hợp.
propertyChuỗi, không bắt buộcThuộc tính để sắp xếp, nếu sắp xếp.
ascendingBoolean, không bắt buộcSắp xếp theo thứ tự tăng dần hay giảm dần. Giá trị mặc định là true (tăng dần).

Ví dụ

Trình soạn thảo mã (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}));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về Python API và cách sử dụng geemap cho quá trình phát triển có tính tương tác.

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