3

I have received an output in GEE code editor in the form of a list of lists of numbers as shown below:

var list1 = ee.List([[1.7,2.4,3.1],[1.3,2.7,3.1],[1.4,2.4,3.2],[1.9,2.8,3.7]]);

I want to export this result in the form of a csv and for this, I tried the following:

Export.table.toDrive(ee.FeatureCollection(list1));

But it throws the error citing this:

Collection, argument 'features': Invalid type. Expected: List<Element>. Actual: List<List<Float>>.

Can you help as I am unable to understand where the problem is?

1 Answer 1

2

First, you don't need to use Export to be able to reproduce the error, just use print:

var list1 = ee.List([[1.7,2.4,3.1],[1.3,2.7,3.1],[1.4,2.4,3.2],[1.9,2.8,3.7]]);
var fc = ee.FeatureCollection(list1)
print(fc)

Collection, argument 'features': Invalid type. Expected: List<Element>. Actual: List<List<Float>>

Depending in the output you want is what you have to do. I show you just a csv with one column with name list and one row (the Feature):

You have to create a Feature with a property in which you will "store" that list, and then create a FeatureCollection with that Feature

var list1 = ee.List([[1.7,2.4,3.1],[1.3,2.7,3.1],[1.4,2.4,3.2],[1.9,2.8,3.7]]);
var features = ee.FeatureCollection([ee.Feature(null, {'list': list1})])
print(features)
2
  • It worked but a further clarification required, please: the output csv when opened in excel environment gives the complete list in one cell. Is it possible to export such that it takes some kind of easily workable format?
    – user95904
    Commented Dec 2, 2019 at 12:19
  • 1
    that is why I said "Depending in the output you want is what you have to do". Take in count that every Feature is a row, so if you want many rows, you'll have to write many features Commented Dec 2, 2019 at 12:48

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.