I have a feature collection but I need to make a new feature collection from it by taking only some columns , I am new to google earth engine and am unable to do so ,the code is
NDVI=NDVI.map(function(
f=ee.Feature(f)
return ee.Feature(f.toDictionary(dates).values(dates))
})
print(NDVI)
here NDVI is the main feature collection and
dates is a list of properties that I want to extract per feature, the error I am getting is
FeatureCollection (Error)
Collection.map: A mapped algorithm must return a Feature or Image.
Best Answer
I think this should work:
First of all, you have some syntax errors in your example code. You need to give the inputs of the function, here that is "(f)", after the "function" statement. Then you also forgot the curly opening bracket "{".
The documentation for "ee.Feature" says you need to give a geometry first, and then a dictionary with properties for the respective feature. In this case we say the geometry is non-existant, i.e. "null". The dictionary is create by calling the "toDictionary" method on the input feature "f". Dates needs to be a list of property names that exist in the features of the NDVI feature-collection.
Also note that there is no need to call the ".values(dates)" method, because that will turn the dictionary into a list.