geetools.List
#
Extra methods for the ee.List
class.
Package Contents#
Classes#
Toolbox for the |
- class geetools.List.ListAccessor(obj)[source]#
Toolbox for the
ee.List
class.Initialize the List class.
- Parameters:
obj (ee.List) –
- complement(other)[source]#
Compute the complement of the current list and the
other
list.The mthematical complement is the list of elements that are in the current list but not in the
other
list and vice-versa.- Parameters:
other (geetools.types.ee_list) – The list to compute the complement with.
- Returns:
A list of strings corresponding to the complement of the current list and the
other
list.- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l1 = ee.List(["1", "2", "3"]) l2 = ee.List(["2", "3", "4"]) l1.geetools.complement(l2).getInfo()
- delete(index)[source]#
Delete an element from a list.
- Parameters:
index (geetools.types.ee_int) – The index of the element to delete.
- Returns:
The list without the element at the given index.
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l = ee.List(["a", "b", "c"]) l.geetools.delete(1).getInfo()
- intersection(other)[source]#
Compute the intersection of the current list and the
other
list.The intersection is the list of elements that are in both lists.
- Parameters:
other (geetools.types.ee_list) – The list to compute the intersection with.
- Returns:
A list of strings corresponding to the intersection of the current list and the
other
list.- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l1 = ee.List(["1", "2", "3"]) l2 = ee.List(["2", "3", "4"]) l1.geetools.intersection(l2).getInfo()
- join(separator=', ')[source]#
Format a list to a string.
Same as the join method but elements that cannot be stringified will be returned as the object type.
- Parameters:
separator (geetools.types.ee_str) – The separator to use.
- Returns:
A string with the list elements separated by commas.
- Return type:
ee.string
Examples
import ee, geetools ee.Initialize() l = ee.List(['a', 1, ee.Image(0)]) l.geetools.join().getInfo()
- product(other)[source]#
Compute the cartesian product of 2 list.
Values will all be considered as string and will be joined with no spaces.
- Parameters:
other (geetools.types.ee_list) – The list to compute the cartesian product with.
- Returns:
A list of strings corresponding to the cartesian product.
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l1 = ee.List(["1", "2", "3"]) l2 = ee.List(["a", "b", "c"]) l1.geetools.product(l2).getInfo()
- replaceMany(replace)[source]#
Replace many values in a list.
- Parameters:
replace (geetools.types.ee_dict) – the dictionary with the values to replace. the keys are the values to replace and the values are the new values.
- Returns:
A list with the values replaced
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l = ee.List(["a", "b", "c"]) replace = ee.Dictionary({"a": "foo", "c": "bar"}) l = l.geetools.replaceMany(replace) l.getInfo()
- classmethod sequence(ini, end, step=1)[source]#
Create a sequence from ini to end by step.
Similar to
ee.List.sequence
, but if end != last item then adds the end to the end of the resuting list.- Parameters:
ini (geetools.types.ee_int) – The initial value of the sequence.
end (geetools.types.ee_int) – The final value of the sequence.
step (geetools.types.ee_int) – The step of the sequence.
- Returns:
A list of numbers corresponding to the sequence.
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l = ee.List.geetools.sequence(0, 10, 2) l.getInfo()
- toStrings()[source]#
Convert elements of a list into Strings.
If the list contains other elements that are not strings or numbers, it will return the object type. For example, [‘a’, 1, ee.Image(0)] -> [‘a’, ‘1’, ‘Image’].
- Returns:
A list of strings corresponding to the elements of the list.
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l = ee.List(["a", 1, ee.Image(0)]) l.geetools.toStrings().getInfo()
- union(other)[source]#
Compute the union of the current list and the
other
list.This list will drop duplicated items.
- Parameters:
other (geetools.types.ee_list) – The list to compute the union with.
- Returns:
A list of strings corresponding to the union of the current list and the
other
list.- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l1 = ee.List(["1", "2", "3"]) l2 = ee.List(["2", "3", "4"]) l1.geetools.union(l2).getInfo()
- zip()[source]#
Zip a list of lists.
The nested lists need to all have the same size. The size of the first element will be taken as reference.
- Returns:
A list of lists with the zipped elements
- Return type:
ee.List
Examples
import ee, geetools ee.Initialize() l = ee.List([[1,2,3], [4,5,6], [7,8,9]]) l.geetools.zip().getInfo()