geetools.ComputedObject#

Extra tools for the ee.ComputedObject class.

Package Contents#

Classes#

Float

Placeholder Float class to be used in the isInstance method.

Integer

Placeholder Integer class to be used in the isInstance method.

Functions#

isInstance(self, klass)

Return 1 if the element is the passed type or 0 if not.

save(self, path)

Save a ComputedObject to a .gee file.

class geetools.ComputedObject.Float[source]#

Placeholder Float class to be used in the isInstance method.

Avoid initializing the class.

__name__()[source]#

Return the class name.

class geetools.ComputedObject.Integer[source]#

Placeholder Integer class to be used in the isInstance method.

Avoid initializing the class.

__name__()[source]#

Return the class name.

geetools.ComputedObject.isInstance(self, klass)[source]#

Return 1 if the element is the passed type or 0 if not.

Parameters:

klass (Type) – The class to check the instance of.

Returns:

1 if the element is the passed type or 0 if not.

Return type:

ee.Number

Examples

import ee, geetools

ee.Initialize()

s = ee.String("foo").isInstance(ee.String)
s.getInfo()
geetools.ComputedObject.save(self, path)[source]#

Save a ComputedObject to a .gee file.

The file contains the JSON representation of the object. it still need to be computed via getInfo() to be used.

Parameters:

path (geetools.types.pathlike) – The path to save the object to.

Returns:

The path to the saved file.

Return type:

pathlib.Path

Examples

import ee, geetools
from tempfile import TemporaryDirectory
from pathlib import Path

ee.Initialize()

img = ee.Image("COPERNICUS/S2/20151128T112653_20151128T135750_T29SND")
with TemporaryDirectory() as tmp:
    file = Path(tmp) / "test.gee"
    img.geetools.save(file)
    print(file.readText())
static geetools.ComputedObject.open(path)[source]#

Open a .gee file as a ComputedObject.

Parameters:

path (geetools.types.pathlike) – The path to the file to open.

Returns:

The ComputedObject instance.

Return type:

ee.ComputedObject

Examples

import ee, geetools
from tempfile import TemporaryDirectory
from pathlib import Path

ee.Initialize()

img = ee.Image("COPERNICUS/S2/20151128T112653_20151128T135750_T29SND")
with TemporaryDirectory() as tmp:
    file = Path(tmp) / "test.gee"
    img.geetools.save(file)
    obj = ee.Image.open(file)
    print(obj)