ee.FeatureCollection.aggregate_histogram
Aggregates over a given property of the objects in a collection, calculating a histogram of the selected property.
Usage | Returns |
---|
FeatureCollection.aggregate_histogram(property) | Dictionary |
Argument | Type | Details |
---|
this: collection | FeatureCollection | The collection to aggregate over. |
property | String | The property to use from each element of the collection. |
Examples
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
print('Histogram of power plant capacities (MW)',
fc.aggregate_histogram('capacitymw')); // Dictionary
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
from pprint import pprint
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"')
print('Histogram of power plant capacities (MW):')
pprint(fc.aggregate_histogram('capacitymw').getInfo()) # Dictionary
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["Computes a histogram for a specified property within a FeatureCollection."],["Returns a dictionary where keys represent property value ranges and values represent the frequency of features within that range."],["Useful for understanding the distribution of a specific attribute, such as the capacity of power plants in a region."]]],["The `aggregate_histogram` method calculates a histogram for a specified property across a FeatureCollection. It takes the collection and the property name as input. The output is a dictionary representing the histogram. In the provided examples, a FeatureCollection of Belgian power plants is used, and a histogram of their capacities (in MW) is generated using `aggregate_histogram('capacitymw')`. The method works on both the Javascript and Python Earth Engine APIs.\n"]]