Suppose I have a featurecollection
, including two aa
.
How can I reduce (maybe other functions) the featurecollection by calculate the mean value of aa
?
Before
var features = [
ee.Feature(ee.Geometry.Point(11, 22), {name: 'aa',value:10}),
ee.Feature(ee.Geometry.Point(33, 44), {name: 'bb',value:20}),
ee.Feature(ee.Geometry.Point(11, 22), {name: 'aa',value:30}),
ee.Feature(ee.Geometry.Point(55, 66), {name: 'cc',value:40})
];
var fromList = ee.FeatureCollection(features);
After
var features = [
ee.Feature(ee.Geometry.Point(11, 22), {name: 'aa',value:20}), // (10+30)/2
ee.Feature(ee.Geometry.Point(33, 44), {name: 'bb',value:20}),
ee.Feature(ee.Geometry.Point(55, 66), {name: 'cc',value:40})
];
Best Answer
Basically you want to itirate over the unique identifier, name in your case. and filter all features that match it, compute the mean and overwrite it. This should do the trick:
https://code.earthengine.google.com/2307664929ac4485abc1c8708c5e3d6f