Google Earth Engine Layer¶
Greppo supports the visualization and the usage of Google-Earth-Engine (GEE). You could use this to build your GEE apps in Python.
Before you can use this service, you must make sure you have access to Google Earth Engine. If not, signup to the service and wait to recieve a confirmation: GEE-Sign-Up
Parameters¶
ee_object
Pass in the earth engine image object that you would like to render on the UI. It supports the following earth engine objects Image
, ImageCollection
, Geometry
, Feature
and FeatureCollection
.
name
Name string value rendered on the UI, to reference it to the layer.
description
Description string value rendered on the UI.
vis_params
The visualisation parameters depending on the objects that have been created. For a reference check out (developer.google.com/earth-engine), or check the quick reference below.
visible
Boolean toggle to turn this layer on or off.
opacity
Change the opacity of the layer using a float
value between 0.0
and 1.0
.
vis_param
: visualisation parameters quick-reference¶
FeatureCollection & Feature¶
The visualization parameters. Currently only one parameter, ‘color’, containing an RGB color string is allowed. If vis_params isn’t specified, then the color #000000 is used.
ImageCollection & Image¶
Argument |
Type |
Details |
---|---|---|
bands |
Object, default: null |
A list of the bands to visualize. If empty, the first 3 are used. |
gain |
Object, default: null |
The visualization gain(s) to use. |
bias |
Object, default: null |
The visualization bias(es) to use. |
min |
Object, default: null |
The value(s) to map to RGB8 value 0. |
max |
Object, default: null |
The value(s) to map to RGB8 value 255. |
gamma |
Object, default: null |
The gamma correction factor(s) to use. |
opacity |
Number, default: null |
The opacity scaling factor to use. |
palette |
Object, default: null |
The color palette to use. List of CSS color identifiers or hexadecimal color strings (e.g. [‘red’, ‘00FF00’, ‘bluevlolet’]). |
Authentication¶
To further use GEE in Greppo, you must have a service account configured to use GEE. Follow the instructions presented here: GEE-Service-Account
You will then recieve a service-account-email-address
and a key_file.json
, which you will then use for making a Greppo app.
Note: Use environmental variables and store the key_file.json
away from your project folder. These credentails must be kept private.
credentials = ee.ServiceAccountCredentials(email, key_file=None, key_data=None)
ee.Initialize(credentials)
"""
Authenticate earthengine-api using a Service-Account-Credential
email: The email address of the account for which to configure credentials.
Ignored if key_file or key_data represents a JSON service account key.
email = my-service-account@...gserviceaccount.com
email = greppo-ee-test@greppo-earth-engine.iam.gserviceaccount.com
key_file: The path to a file containing the private key associated with
the service account. Both JSON and PEM files are supported.
key_data: Raw key data to use, if key_file is not specified.
"""
Usage¶
from greppo import app
import ee
email = 'my-service-account@...gserviceaccount.com'
key_file = 'path-to/key_file.json'
credentials = ee.ServiceAccountCredentials(email=email, key_file=key_file)
ee.Initialize(credentials)
dem = ee.Image('USGS/SRTMGL1_003')
ee_image_object = dem.updateMask(dem.gt(0))
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}
name = 'DEM'
app.ee_layer(ee_object=ee_image_object, vis_params=vis_params, name=name)