0

I need to convert a Feature Collection containing only numeric data to a 2D matrix. I have written the following code however it gives matA as a list of arrays despite explicit type conversion, here table is my feature collection and data is the list of properties I need to extract into the matrix

// list of data to extract from FC
var data=ee.List(['bio01','bio02','bio03','bio04','bio05','bio06','bio07',
 'bio08','bio09','bio10','bio11','bio12','bio13','bio14', 
 'bio15','bio16','bio17','bio18','bio19','dem','tmax','tmin','prec']);
//data becomes the list from which the user wants to remove the ones he doesn't need
var tableArray=table.toList(200,0) // list of features
var tableList=ee.List(tableArray.map(function(element){
 var feat=ee.Feature(element) 
 var array=feat.toArray(data) //feature to array
 return ee.List(array) //array to list 
}))
// array needs all elements of list only not array inside list so we change feature to list
var matA=ee.Array(tableList)
print(matA)

The error I am getting is:

Array (Error)
Array: Unrecognized type, may only use numbers or lists, found type Array.
asked Jun 25, 2018 at 7:29

1 Answer 1

1

The following code works to convert feature collection to arrays

var tableList = table.toList(200).map(function(element) {
 return ee.Feature(element).toArray(data)
})
var matA = ee.Array.cat(tableList, 1)
answered Jun 27, 2018 at 7:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.