0

I want to get possible combinations of two sets of lists in google earth engine, but my code did not works.

var Per1= ee.Array([[0.1,0.5,0.8],[0.4,0.5,0.2]])
var pre = PercFin1.toList()

var CC=ee.List([1,2,3]);

var ZZ = pre.map(function(hh){
var Per11 = ee.List(pre).get(hh);
var out = CC.zip(Per11);
return out;
});
print (ZZ)

The error I get is:

List.get, argument 'index': Invalid type. Expected: Integer. Actual: List.

Thanks in advance

HamiEbra
  • 310
  • 2
  • 7

1 Answers1

1

I don't know if this is what you want, but it looks like you've got the right idea but made an incidental mistake: hh is not an index into pre but an element of it.

I modified and simplified the last part of your code (along with changing PercFin1 to Per1, which I assume was a typo):

var ZZ = pre.map(function(hh){
  return CC.zip(hh);
});
print(ZZ);

The result of this is

[
  [[1,0.1],[2,0.5],[3,0.8]],
  [[1,0.4],[2,0.5],[3,0.2]]
]

which is what I understand you want — each row in Per1 individually zipped with CC.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108