0

I am using 'featureCollection.features.forEach()' inorder to loop over a featurecollection and make some changes to each feature. after each iteration I want to export a CSV file. I want to name each file with a specific property of the feature ('my_index') but I am getting this error: feature.get is not a function.

  sheds.select(['my_index']).evaluate(function (featureCollection) {
        featureCollection.features.forEach(function (feature) {
    
        var file_name = feature.get('grdc_no');
    
        Export.table.toDrive({  
        collection: table_precip,
        description: file_name,    //get name of the file from the property 'my_index'
        folder: 'rain test',
        fileFormat: 'CSV',
        });
      });
    });
0

1 Answer 1

1

You've already extracted all the data from Earth Engine using the evaluate function, so you can no longer use Earth Engine functions on the results. The feature you have inside the function is going to have a properties dictionary in it, and the variable you're trying to access will be inside that. So you'd access it with something like this instead of using get():

feature['properties']['grdc_no']

But you won't then be able to export the results, since they're in your browser and no longer in Earth Engine.

If the bigger picture of what you're trying to do is to export each feature to its own file, then I think it would be easier to just split them up once you've downloaded all of them.

1
  • thank you, it was helpfull
    – Ward Bahri
    Commented May 5, 2022 at 18:23

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.