ee.FeatureCollection.aggregate_count

对集合中对象的给定属性进行汇总,计算该属性的非 null 值数量。

用法返回
FeatureCollection.aggregate_count(property)数字
参数类型详细信息
此:collectionFeatureCollection要汇总的集合。
property字符串要从集合的每个元素中使用的属性。

示例

代码编辑器 (JavaScript)

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

print('Number of non-null values for the fuel1 property',
      fc.aggregate_count('fuel1'));  // 66

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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('Number of non-null values for the fuel1 property:',
      fc.aggregate_count('fuel1').getInfo())  # 66