Using geemap with Google Colab
Introduction
This notebook demonstrates how to use geemap with Google Colab. To use geemap and the Earth Engine Python API, you must register for an Earth Engine account and follow the instructions here to create a Cloud Project. Earth Engine is free for noncommercial and research use.
Install geemap
The geemap package is pre-installed in Google Colab and is updated to the latest minor or major release every few weeks. If you would like to install the latest version, you can uncomment and run the following command:
Import libraries
Import the Earth Engine Python API.
EE Authentication
Running the following cell will start the Earth Engine authentication. Follow the instructions here to authenticate Earth Engine.
Core features
You can import the geemap package using the following conventions:
To import only the core features of geemap, use:
import geemap.core as geemapTo import all the features of geemap, use:
import geemap
Let's import the geemap package using the second option:
Basemap selector
Select a basemap from the dropdown list and add it to the map.
Layer Manager
Toggle the checkbox to show or hide the layer. Drag and move the slider to change the transparency level of the layer.
Inspector
Click on the map to query Earth Engine data at a specific location.
Layer Editor
You can change the visualization parameters of the Earth Engine data using the layer editor.
Single-band image
Multi-band image
Feature collection
Draw control
You can draw shapes on the map using the draw control. The drawn features will be automatically converted to Earth Engine objects, which can be accessed in one of the following ways:
To return the last drawn feature as an
ee.Geometry(), use:m._draw_control.last_geometryTo return all the drawn feature as an
ee.Feature(), use:m._draw_control.last_featureTo return all the drawn features as an
ee.FeatureCollection(), use:m._draw_control.collection
Use the draw control to draw a polygon on the map.
Clip the DEM data using the drawn polygon.