Table of Contents

Pydeck EarthEngineLayer

@unfolded.gl/earthengine-layers

The pydeck EarthEngineLayer connects Google Earth Engine to pydeck, making it possible to visualize planetary-scale geospatial datasets from Python.

To use this layer, you'll need to authenticate with an EarthEngine-enabled Google Account. Visit here to sign up.

from pydeck_earthengine_layers import EarthEngineLayer
import pydeck as pdk
import ee

# Initialize Earth Engine library
ee.Initialize()

# Create an Earth Engine object
image = ee.Image('CGIAR/SRTM90_V4')

# Define Earth Engine visualization parameters
vis_params = {
    "min": 0, 
    "max": 4000,
    'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']
}

# Create a pydeck EarthEngineLayer object, using the Earth Engine object and
# desired visualization parameters
ee_layer = EarthEngineLayer(image, vis_params)

# Define the initial viewport for the map
view_state = pdk.ViewState(latitude=37.7749295, longitude=-122.4194155, zoom=10, bearing=0, pitch=45)

# Create a Deck instance, and display in Jupyter
r = pdk.Deck(layers=[ee_layer], initial_view_state=view_state)
r.show()

Installation

See the pydeck integration guide for installation instructions.

EarthEngineLayer

The pydeck-earthengine-layer package exports the EarthEngineLayer class. This makes interfacing with EarthEngine easy: behind the scenes it handles authentication, loading the EarthEngine JavaScript library, and correctly passing the EarthEngine objects to JavaScript.

Arguments

  • ee_object: (required), an instance of a Python EarthEngine object, such as an ee.Image, ee.ImageCollection, ee.FeatureCollection, etc.
  • vis_params: (dict, optional), parameters for how to visualize the EarthEngine object. See EarthEngine documentation for expected dict layout. Default: None.
  • credentials: (optional), Google OAuth2 credentials object. Default: saved credentials are loaded automatically.
  • library_url: (str, optional), Force loading of the JavaScript EarthEngineLayer bundle for a specific URL. By default, loads from the most recent EarthEngineLayer release.

All properties accepted by the JavaScript EarthEngineLayer are accepted as keyword arguments. So, for example, to animate an ee.ImageCollection from Python, you can pass

EarthEngineLayer(ee.ImageCollection(...), animate=True)

Source

py/pydeck_earthengine_layers/