This is an example of using pydeck to visualize a Google Earth Engine FeatureCollection
of polygons.
To install and run this notebook locally, refer to the Pydeck Earth Engine documentation.
To see this example online, view the JavaScript version.
Import required packages:
from pydeck_earthengine_layers import EarthEngineLayer
import pydeck as pdk
import ee
Using Earth Engine requires authentication. If you don't have a Google account approved for use with Earth Engine, you'll need to request access. For more information and to sign up, go to https://signup.earthengine.google.com/.
try:
ee.Initialize()
except Exception as e:
ee.Authenticate()
ee.Initialize()
This example uses the Large Scale International Boundary Polygons dataset, which contains simplified boundaries of countries.
Import the dataset by creating an Earth Engine object that references it.
dataset = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')
Apply Earth Engine styling on this dataset. Here we render the fill of the polygon with a shade of green, and the border color with a shade of blue.
countries = dataset.style(
fillColor='b5ffb4',
color='00909F',
width=3
)
Create a new EarthEngineLayer
with this dataset that can then be passed to Pydeck.
layer = EarthEngineLayer(countries, id="international_boundaries")
Then just pass this layer to a pydeck.Deck
instance, and call .show()
to create a map:
view_state = pdk.ViewState(latitude=36, longitude=10, zoom=3)
r = pdk.Deck(
layers=[layer],
initial_view_state=view_state
)
r.show()