AI-generated Key Takeaways
-
makeArray()
combines specified numeric properties of features within a FeatureCollection into a new 1-D array property. -
Features lacking any of the specified properties, or containing non-numeric values in those properties, are excluded from the output.
-
The resulting FeatureCollection contains the original features with an added array property holding the combined values.
-
The array property is named using the 'name' argument, defaulting to "array" if not provided.
Usage | Returns |
---|---|
FeatureCollection.makeArray(properties, name) | FeatureCollection |
Argument | Type | Details |
---|---|---|
this: collection | FeatureCollection | The input collection from which properties will be selected. |
properties | List | The properties to select. |
name | String, default: "array" | The name of the new array property. |
Examples
Code Editor (JavaScript)
// FeatureCollection of power plants in Belgium. var fc = ee.FeatureCollection('WRI/GPPD/power_plants') .filter('country_lg == "Belgium"'); // A list of feature properties to combine into an array // (power generation by year). var properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016']; // Add array of power-generation-by-year property to features. fc = fc.makeArray(properties, 'gwh_by_year'); print('FeatureCollection with array of selected properties added', fc); print('See example of new "gwh_by_year" property', fc.first().toDictionary());
import ee import geemap.core as geemap
Colab (Python)
from pprint import pprint # FeatureCollection of power plants in Belgium. fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter( 'country_lg == "Belgium"') # A list of feature properties to combine into an array # (power generation by year). properties = ['gwh_2013', 'gwh_2014', 'gwh_2015', 'gwh_2016'] # Add array of power-generation-by-year property to features. fc = fc.makeArray(properties, 'gwh_by_year') print('FeatureCollection with array of selected properties added:', fc.getInfo()) print('See example of new "gwh_by_year" property:') pprint(fc.first().toDictionary().getInfo())