What I need is to add Point, Object and Date Ids to the before NDVI Mean value. Such that when I export my feature collection it has the point id(Objectid), date id, and mean NDVI parameters. These parameters are highlighted in the image below;
At the moment when I export, I only get the mean ndvi value.
The date and point id are the most important values needed. These parameters are properties of the Invasion_buffers future collection. Looking forward to a solution.
I have written a function but it returns an error; FeatureCollection (Error)
Error in map(ID=00000000000000000008):
Dictionary: Element at position 0 is not a string.
The function;
//Formatting the before invasion mean ndvi values before exporting
var format = function(table, rowId, colId) {
var rows = table.distinct(rowId);
var joined = ee.Join.saveAll('matches').apply({
primary: rows,
secondary: table,
condition: ee.Filter.equals({
leftField: rowId,
rightField: rowId
})
});
return joined.map(function(row) {
var values = ee.List(row.get('matches'))
.map(function(feature) {
feature = ee.Feature(feature);
var ndvi = ee.List([feature.get('BF_NDVI'), -9999]).reduce(ee.Reducer.firstNonNull())
return [feature.get(colId), ee.Number(ndvi).format('%.2f')];
});
return row.select([rowId]).set(ee.Dictionary(values.flatten()));
});
};
// var id = function (feature) {
// var id = invasionbuffer.get('id').format('%05d');
// return feature;
// };
var bfndviexp = format(invasionbuffer, 'date', 'BF_NDVI')
print('Bf_Ndvi_Export', bfndviexp)
The function is found in lines 137-170 of this script; https://code.earthengine.google.com/d5e51b426b5e77cdb002c641d2504434
Best Answer
@Shiraz If I correctly understand your problem then you can go with this function.
https://code.earthengine.google.com/611dbb2c1d3d396d0669aba6a748f1a5