list of list

I have a list of lists (you can see on the pic), and would like to export it as .csv. I tried to convert it into feature collection, and then run the following lines:

var feature = ee.Feature(null, lossperyearperelevation1);
var featureCollection = ee.FeatureCollection([feature]);
  collection: featureCollection,
  description: 'exportTableExample',
  fileFormat: 'CSV'});

it gives the following error: Error: Feature, argument 'metadata': Invalid type. Expected type: Dictionary. Actual type: List<List<Dictionary>>.

I am confused if it is a list of list, and how to export it in .csv. How can I solve this problem?

the link for the sample code is here: https://code.earthengine.google.com/40c2c24233a6119ee577fb05dd86a14e

  • 1
    The error you're receiving part of "converting it into feature collection", not from the Export operation. We need more information — could you please edit your question to include the "converting" code, and preferably a sample list of lists of dictionaries to run it on? Also, what shape of CSV output are you hoping to get? An example CSV file written out would help.
    – Kevin Reid
    Jan 21, 2021 at 15:20
  • Hey @KevinReid I added Export code and the link to my question. Well, I do not exatly know what shape of CSV i want. I just need to export all the data in a way that I can see the loss per year in different elevations. I am not sure if it is feasible, but I am open to any suggestion! Jan 21, 2021 at 16:38
  • The error is at line 57 with the var feature = ee.Feature(null, lossperyearperelevation1); var featureCollection = ee.FeatureCollection([feature]); Jan 21, 2021 at 17:17
  • @UdithaHerath do you have any idea how to fix it? Jan 24, 2021 at 13:27

1 Answer 1


The grouped reducer output are always a bit messy. Here is a way to rework your output to a feature collection:

// rework output
var featureCollection = ee.FeatureCollection(lossperyearperelevation1.map(function(element){
  element = ee.Dictionary(element); // cast
  var list = ee.List(element.get('groups'));
  var feats = ee.FeatureCollection(list.map(function(listEl){
    var dict = ee.Dictionary(listEl);
    return ee.Feature(null, dict);
  return feats

As there are not so many comments in your code, it is hard to understand what your goal is. Link code

  • how can I learn the logic behind this code? I would like to understand how to convert different data types to a feature collection in GEE. I will need to use this in the coming part of my study. Do you have any suggestions for me regarding that? Any document, and webpage...? Feb 24, 2021 at 10:22

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.