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

    return ee.Feature(f.toDictionary(dates).values(dates))

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.

1 Answer 1


I think this should work:

var dates = ee.List(["property1", "property2"]);

var new_NDVI=NDVI.map(function(f){
    f = ee.Feature(f);
    return ee.Feature(null, f.toDictionary(dates));

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.