-
Notifications
You must be signed in to change notification settings - Fork 111
Tools
This is the most important module of the package. It is divided in the following scopes:
NOTE: In all examples it's assumed that the module is imported at first:
var tools = require('users/fitoprincipe/geetools:tools');
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
Make a random number from start
to end
. Argument type
can be float
or int
Trim decimals from a float number n places
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]
Remove duplicated items
Return the intesection between list1
and list2
Extract values from a dictionary that match keys from the given list
var list = ['a', 'c']
var dict = {a: 1, b:2, c:3}
var values = tools.dictionary.extractList(dict, list)
print(values) // [1, 3]
https://code.earthengine.google.com/e6200496f6089e6cd4eab8d7f009668a
Mask pixels inside a geometry. It return a function to map
over an ImageCollection
.
var i = ee.Image.random(1)
var masked = tools.geometry.maskInside(geometry)(i)
Map.addLayer(masked, {}, 'maskInside')
// over a collection
var col = ee.ImageCollection('collectionID')
var masked_col = col.map(tools.geometry.maskInside(geometry))
https://code.earthengine.google.com/e9eb4aba7465abfbdbfaeb45bd404b1f
Paints geometries. Similar to ee.Image.paint
but with some differences. Argument options
must be an object
with none, one or more of the following:
fillColor
borderColor
-
border
(border's thickness) -
idFld
(field that contains a numeric property)
https://code.earthengine.google.com/87c00a8b9796d601553051c84652694f
- @author: Rodrigo E. Principe
- email: fitoprincipe82 at gmail
- Licence: MIT