Spatial Querying of GEDI Version 2 Data in Python

The Global Ecosystem Dynamics Investigation (GEDI) mission aims to characterize ecosystem structure and dynamics to enable radically improved quantification and understanding of the Earth's carbon cycle and biodiversity. The Land Processes Distributed Active Archive Center (LP DAAC) distributes the GEDI Level 1 and Level 2 Version 1 and Version 2 products. The LP DAAC created the GEDI Finder Web Service to allow users to perform spatial queries of GEDI Version 1 L1-L2 full-orbit granules. One of the updates for GEDI Version 2 included additional spatial metadata that allows users to perform spatial queries via a graphical user interface (GUI) using NASA's Earthdata Search or programmatically using NASA's Common Metadata Repository (CMR). Another update is that each GEDI V1 full-orbit granule has been divided into 4 sub-orbit granules in V2.


Use Case Example:

This tutorial was developed using an example use case for a current GEDI Finder user who has been using the GEDI Finder web service in Python to find intersecting GEDI L2A Version 1 full-orbit granules over the Amazon Rainforest. The user is now looking to use the same workflow to find intersecting GEDI L2A V2 sub-orbit granules.

This tutorial will show how to use Python to perform a spatial query for GEDI V2 data using NASA's CMR, how to reformat the CMR response into a list of links pointing to the intersecting sub-orbit granules on the LP DAAC Data Pool, and how to export the list of links as a text file.


Applicable Data Products:

This tutorial can be used to perform spatial queries on the following products:


Topics Covered:

  1. Import Packages
  2. Define Function to Query CMR
  3. Execute GEDI_Finder Function
  4. Export Results

Before Starting this Tutorial:

Setup and Dependencies

It is recommended to use Conda, an environment manager to set up a compatible Python environment. Download Conda for your OS here: https://www.anaconda.com/download/. Once you have Conda installed, Follow the instructions below to successfully setup a Python environment on Linux, MacOS, or Windows.

This Python Jupyter Notebook tutorial has been tested using Python version 3.8. Conda was used to create the python environment.

If you do not have Jupyter Notebook installed, you may need to run:

conda install jupyter notebook

Having trouble getting a compatible Python environment set up? Contact LP DAAC User Services at: https://lpdaac.usgs.gov/lpdaac-contact-us/

If you prefer to not install Conda, the same setup and dependencies can be achieved by using another package manager such as pip.


Source Code used to Generate this Tutorial:

The repository containing the files is located at: https://git.earthdata.nasa.gov/projects/LPDUR/repos/gedi-finder-tutorial-python/browse

If you prefer to execute the code used in this tutorial outside of a Jupyter Notebook, a python script version is available:


1. Import Packages

All of the packages required to execute this tutorial are included in the Python Standard Library.

2. Define Function to Query CMR

In the code cell below, define a function called gedi_finder that takes two user-submitted input values, a product and a bbox.

There are three available products for this function, including 'GEDI01_B.002', 'GEDI02_A.002' and 'GEDI02_B.002'. A dictionary is set up to relate each product shortname.version to its associated concept_id, which is a value used by NASA's CMR to retrieve data for a specific product. Additional information on concept ID's can be found in the CMR Search API Documentation.

The second user-submitted input value, bbox is a string of bounding box coordinate values (decimal degrees) in the following format:

Lower Left Longitude, Lower Left Latitude, Upper Right Longitude, Upper Right Latitude ("LLLon,LLLat,URLon,URLat")

Example: '-73.65,-12.64,-47.81,9.7'

3. Execute GEDI Finder Function

Below is a demonstration of how to set the two required inputs to the gedi_finder function to variables.

Above, the variables are defined to query the GEDI02_B.002 product for a bounding box covering the Amazon Rainforest.

Next, call the gedi_finder function for the desired product and bounding box region of interest defined above, and set the output to a variable.

Notice the print statement above will notify you how many granules intersected your bounding box for the product requested.

4. Export Results

Additional Resources

Looking to bulk download the intersecting GEDI Version 2 files from your request? Check out the following LP DAAC resources to get you started:

  1. How to Access LP DAAC Data from the Command Line
  2. How to Access the LP DAAC Data Pool with Python
  3. How to Access the LP DAAC Data Pool with R

Also be sure to check out the following GEDI Resources:

  1. GEDI Spatial Querying and Subsetting Quick Guide V2

    Explains how to perform spatial querying and subsetting of GEDI V2 data directly in NASA's Earthdata Search Client

  2. GEDI Spatial and Band/layer Subsetting and Export to GeoJSON (GEDI Subsetter) Script

    Allows you to subset GEDI V2 data by band/layer and region of interest

  3. Getting Started with GEDI L1B, L2A, and L2B Version 2 Data in Python Tutorial Series

    Includes a series of tutorials that demonstrate how to start working with GEDI V2 data in Python.

Contact Information

Material written by Cole Krehbiel$^{1}$

    Contact: LPDAAC@usgs.gov
    Voice: +1-605-594-6116
    Organization: Land Processes Distributed Active Archive Center (LP DAAC)
    Website: https://lpdaac.usgs.gov/
    Date last modified: 05-10-2021
$^{1}$KBR Inc., contractor to the U.S. Geological Survey, Earth Resources Observation and Science (EROS) Center, Sioux Falls, South Dakota, 57198-001, USA. Work performed under USGS contract G15PD00467 for LP DAAC$^{2}$. $^{2}$LP DAAC Work performed under NASA contract NNG14HH33I.