Skip to content
Rodrigo E. Principe edited this page Aug 19, 2019 · 4 revisions

list

sequence(start, end, step)

Make a sequence from start to end each step. Similar to ee.List.sequence but with the difference that the remaining last is included.

var seq = tools.list.sequence(0, 21, 2)
print(seq) // [0,2,4,6,8,10,12,14,16,18,20,21]
var ee_seq = ee.List.sequence(0, 21, 2)
print(ee_seq) // [0,2,4,6,8,10,12,14,16,18,20]

https://code.earthengine.google.com/8cc563cf14c7f60425692b4e0f5c4733

intersection(list1, list2)

Return the intesection between list1 and list2

var tools = require('users/fitoprincipe/geetools:tools');
var list1 = ee.List([1, 2, 3, 4, 5])
var list2 = ee.List([2, 4, 6, 8])
var intersection = tools.list.intersection(list1, list2)
print(intersection)  // [2, 4]

https://code.earthengine.google.com/abbc287e5a2d261187844971367733c0

difference(list1, list2)

Return the difference between list1 and list2. It's the opposite to tools.list.intersection

var tools = require('users/fitoprincipe/geetools:tools');
var list1 = ee.List([1, 2, 3, 4, 5])
var list2 = ee.List([2, 4, 6, 8])
var difference = tools.list.difference(list1, list2)
print(difference)  // [1, 3, 5, 6, 8]

https://code.earthengine.google.com/0bd3aa833c564f444325f6aed25785b1

removeIndex(list, index)

Remove an element by its index.

var tools = require('users/fitoprincipe/geetools:tools');
var list = ee.List([1, 2, 3, 4, 5])
var rem_0 = tools.list.removeIndex(list, 0)
print(rem_0)  // [2, 3, 4, 5]
var rem_last = tools.list.removeIndex(list, 4)
print(rem_last)  // [1, 2, 3, 4]
var rem_mid = tools.list.removeIndex(list, 2)
print(rem_mid)  // [1, 2, 4, 5]
var rem_out = tools.list.removeIndex(list, 5)
print(rem_out)  // -1

https://code.earthengine.google.com/11fc4cac1b9b5a678149766b8273ea4b

Clone this wiki locally