Skip to content
Rodrigo E. Principe edited this page Oct 25, 2018 · 17 revisions

tools module

This is the most important module of the package. It is divided in the following scopes:

  • string
  • number
  • list
  • dictionary
  • geometry
  • feature
  • image
  • map

NOTE: In all examples it's assumed that the module is imported at first:

var tools = require('users/fitoprincipe/geetools:tools');

string

format(string)

Format a string using curly brackets.

var string = ee.String('Hello {name}')
var formatted = tools.string.format(string, {name: 'Rodrigo'})
print('Formatted string', formatted)

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

number

random(start, end, type)

Make a random number from start to end. Argument type can be float or int

trimDecimals(places)

Trim decimals from a float number n places

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]

removeDuplicates(list)

Remove duplicated items

intersection(list1, list2)

Return the intesection between list1 and list2

`

Clone this wiki locally