Open Source Pipeline to Integrate Drone and Satellite Data
This notebook is designed for workshop presented at the FOSS4G NA 2024 conference on September 9, 2024. Click the "Open in Colab" button above to run this notebook interactively in the cloud.
Registration: https://bit.ly/3X1mBi7
Earth Engine: https://earthengine.google.com
Geemap: https://geemap.org
Leafmap: https://leafmap.org
Data to Science (D2S): https://ps2.d2s.org
D2S Python API: https://py.d2s.org
Acknowledgments
This training material was partially supported by the National Agricultural Producers Data Cooperative (USDA award 2023-77039-41033; Sub-award 25-6231-0428-008).
Introduction
Recent advances in drone technology have revolutionized the remote sensing community by providing means to collect fine spatial and high temporal resolutions at affordable costs. As people are gaining access to increasingly larger volumes of drone and satellite geospatial data products, there is a growing need to extract relevant information from the vast amount of freely available geospatial data. However, the lack of specialized software packages tailored for processing such data makes it challenging to develop transdisciplinary research collaboration around them. This workshop aims to bridge the gap between big geospatial data and research scientists by providing training on an open-source online platform for managing big drone data known as Data to Science. Additionally, attendees will be introduced to powerful Python packages, namely Geemap and Leafmap, designed for the seamless integration and analysis of drone and satellite images in various applications. By participating in this workshop, attendees will acquire the skills necessary to efficiently search, visualize, and analyze geospatial data within a Jupyter environment, even with minimal coding experience. The workshop provides a hands-on learning experience through practical examples and interactive exercises, enabling participants to enhance their proficiency and gain valuable insights into leveraging geospatial data for various research purposes.
Prerequisites
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. To test whether you can use authenticate the Earth Engine Python API, please run this notebook on Google Colab.
It is recommended that attendees have a basic understanding of Python and Jupyter Notebook.
Familiarity with the Earth Engine JavaScript API is not required but will be helpful.
Attendees can use Google Colab to follow this short course without installing anything on their computer.
Agenda
The main topics to be covered in this workshop include:
Create interactive maps
Visualize drone imagery from D2S
Visualize Earth Engine data
Explore Earth Engine Data Catalogs
Analyze Earth Engine data
Create timelapse animations
Introduction to Earth Engine and geemap
Earth Engine is free for noncommercial and research use. For more than a decade, Earth Engine has enabled planetary-scale Earth data science and analysis by nonprofit organizations, research scientists, and other impact users.
With the launch of Earth Engine for commercial use, commercial customers will be charged for Earth Engine services. However, Earth Engine will remain free of charge for noncommercial use and research projects. Nonprofit organizations, academic institutions, educators, news media, Indigenous governments, and government researchers are eligible to use Earth Engine free of charge, just as they have done for over a decade.
The geemap Python package is built upon the Earth Engine Python API and open-source mapping libraries. It allows Earth Engine users to interactively manipulate, analyze, and visualize geospatial big data in a Jupyter environment. Since its creation in April 2020, geemap has received over 3,400 GitHub stars and is being used by over 3,000 projects on GitHub.
Google Colab and Earth Engine Python API authentication
Change Colab dark theme
Currently, ipywidgets does not work well with Colab dark theme. Some of the geemap widgets may not display properly in Colab dark theme.It is recommended that you change Colab to the light theme.

Install geemap
The geemap package is pre-installed in Google Colab and is updated to the latest minor or major release every few weeks. Some optional dependencies of geemap being used by this notebook are not pre-installed in Colab. Uncomment the following code block to install geemap and some optional dependencies.
Import libraries
Import the necessary libraries for this workshop.
Authenticate and initialize 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.
Login to Earth Engine JavaScript Code Editor at https://code.earthengine.google.com and click on th profile icon at the top right. Remember the project ID listed in the dialog that appears. Uncomment the following code block and replace YOUR_PROJECT_ID with your project ID.
Then, run the code block to authenticate and initialize the Earth Engine Python API.
Creating interactive maps
Let's create an interactive map using the ipyleaflet plotting backend. The geemap.Map class inherits 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.
Create a map by specifying the basemap to use as follows. For example, the Esri.WorldImagery basemap represents the Esri world imagery 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:
You can also add an XYZ tile layer to the map.
You can also change basemaps interactively using the basemap GUI.
Visualizing Drone Imagery from D2S
The Data to Science (D2S) platform (https://ps2.d2s.org) hosts a large collection of drone imagery that can be accessed through the D2S API (https://py.d2s.org). To visualize drone imagery from D2S, you need to sign up for a free account on the D2S platform and obtain an API key.
Login method #1
Login procedure using d2spy Auth module.
Login method #2
Login and connect to your D2S workspace in one go using the d2spy
Choosing a project to work with
The Workspace get_projects method will retrieve a collection of the projects your account can currently access on the D2S instance.
The projects variable is a ProjectCollection. The collection can be filtered by either the project descriptions or titles using the methods filter_by_title or filter_by_name.
Now you can choose a specific project to work with. In this case, the filtered projects returned only one project, so we will use that project.
get_project_boundary method of the Project class will retrieve a GeoJSON object of the project boundary.
The Project get_flights method will retrieve a list of flights associated with the project.
The flights variable is a FlightCollection. The collection can be filtered by the acquisition date using the method filter_by_date. This method will return all flights with an acquisition date between the provided start and end dates.
Now, we can choose a flight from the filtered flight. Let's choose the 2018 flight.
The Flight get_data_products method will retrieve a list of data products associated with the flight.
The data_products variable is a DataProductCollection. The collection can be filtered by data type using the method filter_by_data_type. This method will return all data products that match the requested data type.
Now we can grab the ortho URL to display it using geemap.
Similarly, you can visualize the Digital Surface Model (DSM) from D2S using the code below.
Add a colorbar to the map.
Add the project boundary to the map.
Add LiDAR DEM hillshade, DTM, and NDHM to the map.
Retrieve the Ortho data product for the 2023 flight.
Create a split map for comparing the 2018 and 2023 ortho images.
Using Earth Engine data
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:
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:
Visualizing feature collections
Earth Engine Data Catalog
The Earth Engine Data Catalog hosts a variety of geospatial datasets. As of September 2024, the catalog contains over 1,100 datasets with a total size of over 100 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. 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.

Visualizing Earth Engine data
Using the inspector tool
Inspect pixel values and vector features using the inspector tool.
Using the plotting tool
Plot spectral profiles of pixels using the plotting tool.
Set plotting options for Landsat.
Set plotting options for Hyperion.
Legends, color bars, and labels
Built-in legends
Add ESA WorldCover and legend to the map.
https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v200
Custom legends
Add a custom legend by specifying a dictionary of colors and labels.
Creating color bars
Add a horizontal color bar.
Add a vertical color bar.
Make the color bar background transparent.
Split-panel maps
Create a split map with basemaps. Note that ipyleaflet has a bug with the SplitControl. You can't pan the map, which should be resolved in the next ipyleaflet release.
Create a split map with Earth Engine layers.
Timeseries inspector and time slider
Timeseries inspector
Check the available years of NLCD.
Create a timeseries inspector for NLCD. Note that ipyleaflet has a bug with the SplitControl. You can't pan the map, which should be resolved in a future ipyleaflet release.
Generate the NAIP timeseries.
Time slider
Note that this feature may not work properly with in the Colab environment. Restart Colab runtime if the time slider does not work.
Create a map for visualizing MODIS vegetation data.
Create a map for visualizing weather data.
Visualizing Sentinel-2 imagery
Analyzing Earth Engine data
Zonal statistics
Zonal statistics by group
Creating timelapse animations
Landsat timelapse
Sentinel-2 timelapse
MODIS vegetation indices
GOES timelapse
Exercise - Creating timelapse animations
Use the geemap timelapse GUI to create a timelapse animation for any location of your choice. Share the timelapse on social media and use the hashtag such as #EarthEngine and #geemap. See this example.
