ee.FeatureCollection.aggregate_sum

对集合中对象的指定属性进行汇总,计算所选属性值的总和。

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

示例

代码编辑器 (JavaScript)

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

print('Sum of power plant capacities (MW)',
      fc.aggregate_sum('capacitymw'));  // 13288.600000000002

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('Sum of power plant capacities (MW):',
      fc.aggregate_sum('capacitymw').getInfo())  # 13288.600000000002