I'm building a JS script in GoogleEarthEngine. I am automating the code for many year to get a vegetation index (Enhanced Vegetation Index (EVI)) for each year. The code I'm working itself is much more complex, that's why I just added one here for this question.(code here).
I'm trying to get the name of the layer in the key of the JS Object. So it would be:
buffer_size: 500
class: 0
EVI_2021_mean: MEAN_VALUE_FOR_THIS_YEAR
and have in the end, other columns following the same idea, only changing the year value in the Key of the object and its mean value for the Value of the object
The format itself is important to be that way so I can export to KML it afterwards and move on with further analysis.
Instead, what I'm getting is the string 'key' as the Key and the string EVI_2021_mean as the Value.
features: List (4 elements)
0: Feature 0 (Polygon, 3 properties)
type: Feature
id: 1
geometry: Polygon, 24 vertices
properties: Object (3 properties)
buffer_size: 500
class: 0
key: EVI_2021_mean
Obs: I'm setting the mean value inside the GetMean function:
var GetMean = function (fc, img, nome_img) {
print(nome_img);
var dict = [];
var ZS_mean = img.reduceRegion({
reducer: ee.Reducer.mean()
,geometry: POI
,scale: 30
});
dict.push({
key: nome_img+'_'+'mean',
value: ZS_mean.constant
});
print(ZS_mean);
var SetMean = function(f) {
return f.set(dict[0]);
};
return POI.map(SetMean);
};