Interactive Cloud Computing with Google Earth Engine and Geemap
Introduction: This is a notebook prepared for the workshop at the AmericaView Annual Conference at Lafayette, Louisiana on March 13, 2023.
Overview: Google Earth Engine (GEE) is a cloud computing platform with a multi-petabyte catalog of satellite imagery and geospatial datasets. It enables scientists, researchers, and developers to analyze and visualize changes on the Earth’s surface. The geemap Python package provides GEE users with an intuitive interface to manipulate, analyze, and visualize geospatial big data interactively in a Jupyter-based environment. The topics will be covered in this workshop include: (1) introducing geemap and the Earth Engine Python API; (2) creating interactive maps; (3) searching GEE data catalog; (4) visualizing GEE datasets; (5) analyzing GEE datasets, and (6) exporting GEE datasets. More information about the geemap Python package can be found at https://geemap.org.
Requirement: Please sign up for a Google Earth Engine account if you don’t have one yet. No software installation is needed. You just need a browser with Internet access for this workshop.
Import libraries
Authenticate Earth Engine
You will need to create a Google Cloud Project and enable the Earth Engine API for the project. You can find detailed instructions here.
Create interactive maps
Let's create an interactive map using the ipyleaflet plotting backend. The geemap.Map class inherits from the ipyleaflet.Map class. Therefore, you can use the same syntax to create an interactive map as you would with ipyleaflet.Map.
To display it in a Jupyter notebook, simply ask for the object representation:
To customize the map, you can specify various keyword arguments, such as center ([lat, lon]), zoom, width, and height. The default width is 100%, which takes up the entire cell width of the Jupyter notebook. The height argument accepts a number or a string. If a number is provided, it represents the height of the map in pixels. If a string is provided, the string must be in the format of a number followed by px, e.g., 600px.
To hide a control, set control_name to False, e.g., draw_ctrl=False.
Adding basemaps
There are several ways to add basemaps to a map. You can specify the basemap to use in the basemap keyword argument when creating the map. Alternatively, you can add basemap layers to the map using the add_basemap method. Geemap has hundreds of built-in basemaps available that can be easily added to the map with only one line of code.
Built-in basemaps
Create a map by specifying the basemap to use as follows. For example, the HYBRID basemap represents the Google Satellite Hybrid basemap.
You can add as many basemaps as you like to the map. For example, the following code adds the OpenTopoMap basemap to the map above:
Print out the first 10 basemaps:
XYZ tiles
You can also add XYZ tile layers to the map using the Map.add_tile_layer() method. For example, the following code creates an interactive map and adds the Google Terrain basemap to it:
WMS tiles
Similarly, you can add WMS tile layers to the map using the Map.add_wms_layer() method. For example, the following code creates an interactive map and adds the National Land Cover Database (NLCD) 2019 basemap to it:
Earth Engine data types
Earth Engine objects are server-side objects rather than client-side objects, which means that they are not stored locally on your computer. Similar to video streaming services (e.g., YouTube, Netflix, and Hulu), which store videos/movies on their servers, Earth Engine data are stored on the Earth Engine servers. We can stream geospatial data from Earth Engine on-the-fly without having to download the data just like we can watch videos from streaming services using a web browser without having to download the entire video to your computer.
Image: the fundamental raster data type in Earth Engine.
ImageCollection: a stack or time-series of images.
Geometry: the fundamental vector data type in Earth Engine.
Feature: a Geometry with attributes.
FeatureCollection: a set of features.
Image
Raster data in Earth Engine are represented as Image objects. Images are composed of one or more bands and each band has its own name, data type, scale, mask and projection. Each image has metadata stored as a set of properties.
Loading Earth Engine images
Visualizing Earth Engine images
ImageCollection
An ImageCollection is a stack or sequence of images. An ImageCollection can be loaded by passing an Earth Engine asset ID into the ImageCollection constructor. You can find ImageCollection IDs in the Earth Engine Data Catalog.
Loading image collections
For example, to load the image collection of the Sentinel-2 surface reflectance:
Visualizing image collections
To visualize an Earth Engine ImageCollection, we need to convert an ImageCollection to an Image by compositing all the images in the collection to a single image representing, for example, the min, max, median, mean or standard deviation of the images. For example, to create a median value image from a collection, use the collection.median() method. Let's create a median image from the Sentinel-2 surface reflectance collection:
Filtering image collections
FeatureCollection
A FeatureCollection is a collection of Features. A FeatureCollection is analogous to a GeoJSON FeatureCollection object, i.e., a collection of features with associated properties/attributes. Data contained in a shapefile can be represented as a FeatureCollection.
Loading feature collections
The Earth Engine Data Catalog hosts a variety of vector datasets (e.g,, US Census data, country boundaries, and more) as feature collections. You can find feature collection IDs by searching the data catalog. For example, to load the TIGER roads data by the U.S. Census Bureau:
Filtering feature collections
Visualizing feature collections
Earth Engine Data Catalog
The Earth Engine Data Catalog hosts a variety of geospatial datasets. As of March 2023, the catalog contains over 1,000 datasets with a total size of over 40 petabytes. Some notable datasets include: Landsat, Sentinel, MODIS, NAIP, etc. For a complete list of datasets in CSV or JSON formats, see the Earth Engine Datasets List.
Searching for datasets
The Earth Engine Data Catalog is searchable. You can search datasets by name, keyword, or tag. For example, enter "elevation" in the search box will filter the catalog to show only datasets containing "elevation" in their name, description, or tags. 52 datasets are returned for this search query. Scroll down the list to find the NASA SRTM Digital Elevation 30m dataset. On each dataset page, you can find the following information, including Dataset Availability, Dataset Provider, Earth Engine Snippet, Tags, Description, Code Example, and more (see {numref}ch03_gee_srtm). One important piece of information is the Image/ImageCollection/FeatureCollection ID of each dataset, which is essential for accessing the dataset through the Earth Engine JavaScript or Python APIs.

Using the datasets module
Using the inspector tool
Converting JavaScript to Python
Find some Earth Engine JavaScript code that you want to convert to Python. For example, you can grab some sample code from the Earth Engine Documentation.