85 gedi
How to search and download GEDI L4A dataset interactively
This notebook shows how to search and download the GEDI L4A dataset using leafmap. The source code is adapted from the gedi_tutorials repository but has been greatly simplified. Credit goes to ORNL DAAC and Rupesh Shrestha.
Uncomment the following line to install leafmap if needed.
# %pip install -U "leafmap[vector]"
from leafmap import leafmap
Create an interactive map.
m = leafmap.Map(height=600)
m
Use the draw tool to draw a rectangle on the map. If no rectangle is drawn, the default bounding box will be used.
if m.user_roi is not None:
roi = m.user_roi_bounds()
else:
roi = [-73.9872, -33.7683, -34.7299, 5.2444]
Specify the start and end date.
start_date = "2020-07-01"
end_date = "2020-07-31"
Search and download GEDI L4A dataset.
gdf = leafmap.gedi_search(roi, start_date, end_date, add_roi=False, sort_filesize=True)
gdf.head()
id | title | time_start | time_end | granule_size | granule_url | granule_poly | |
---|---|---|---|---|---|---|---|
53 | G2613724953-ORNL_CLOUD | GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201881134... | 2020-07-06T12:43:14.000Z | 2020-07-06T12:46:58.000Z | 47.861555 | https://data.ornldaac.earthdata.nasa.gov/prote... | MULTIPOLYGON (((-44.97207 2.55617, -42.81717 -... |
158 | G2613715991-ORNL_CLOUD | GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20202000651... | 2020-07-18T08:01:01.000Z | 2020-07-18T08:04:33.000Z | 54.162131 | https://data.ornldaac.earthdata.nasa.gov/prote... | MULTIPOLYGON (((-42.53334 -0.01093, -40.37672 ... |
154 | G2613746001-ORNL_CLOUD | GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201992001... | 2020-07-17T20:19:34.000Z | 2020-07-17T20:24:35.000Z | 55.751903 | https://data.ornldaac.earthdata.nasa.gov/prote... | MULTIPOLYGON (((-56.59662 -15.01064, -54.30646... |
86 | G2613716275-ORNL_CLOUD | GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201921001... | 2020-07-10T11:10:20.000Z | 2020-07-10T11:14:01.000Z | 57.355977 | https://data.ornldaac.earthdata.nasa.gov/prote... | MULTIPOLYGON (((-43.26376 0.03918, -41.10744 -... |
192 | G2613743057-ORNL_CLOUD | GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20202040516... | 2020-07-22T06:26:07.000Z | 2020-07-22T06:29:35.000Z | 60.549672 | https://data.ornldaac.earthdata.nasa.gov/prote... | MULTIPOLYGON (((-42.25131 0.03698, -40.09134 -... |
Visualize the GEDI L4A dataset footprints.
m.add_gdf(gdf, layer_name="GEDI footprints")
m
Download the GEDI L4A dataset from NASA EarthData website. You need to register an account first if you don't have one. Create an account at https://urs.earthdata.nasa.gov. Then return to this notebook and uncomment the following code cell to set your username and password.
# import os
# os.environ["EARTHDATA_USERNAME"] = "your_username"
# os.environ["EARTHDATA_PASSWORD"] = "your_password"
leafmap.gedi_download_files(gdf.head(), outdir="data")
Downloading file 1 of 5...
Downloading file 2 of 5...
Downloading file 3 of 5...
Downloading file 4 of 5...
Downloading file 5 of 5...
Read the downloaded GEDI L4A dataset as a GeoDataFrame.
try:
gdf = leafmap.h5_to_gdf(
"data/*.h5", dataset="BEAM0110", columns=["agbd"], nodata=-9999
)
except:
# Download the sample data if the above code fails
gdf = leafmap.geojson_to_gdf(
"https://github.com/opengeos/data/releases/download/v1.0.0/gedi_sample.geojson"
)
gdf.head()
agbd | lat_lowestmode | lon_lowestmode | category | color | geometry | |
---|---|---|---|---|---|---|
0 | 0.294734 | -6.611691 | -38.467288 | 1 | #f7fcf5 | POINT (-38.46729 -6.61169) |
1 | 0.698346 | -6.614202 | -38.465479 | 1 | #f7fcf5 | POINT (-38.46548 -6.61420) |
2 | 0.377637 | -6.704764 | -38.400342 | 1 | #f7fcf5 | POINT (-38.40034 -6.70476) |
3 | 0.655570 | -6.705182 | -38.400042 | 1 | #f7fcf5 | POINT (-38.40004 -6.70518) |
4 | 6.617977 | -6.708118 | -38.397930 | 3 | #74c476 | POINT (-38.39793 -6.70812) |
We can subset the GeoDataFrame by a bounding box. First, create an interactive map and add the bounding box to the map.
m = leafmap.Map(height=620)
roi = [-38.8641, -6.8664, -37.2107, -6.359]
bbox = leafmap.bbox_to_gdf(roi)
m.add_gdf(bbox, layer_name="ROI", zoom_to_layer=True, info_mode=None)
m
Use the bounding box to subset the GeoDataFrame.
subset = leafmap.filter_bounds(gdf, roi, within=True)
Add the subsetted GeoDataFrame to the map. Note that this is only for visualizing a small subset of the data. If you want to work with the entire dataset, you can skip this step.
m.add_data(subset, column="agbd", cmap="Greens", marker_radius=5)
Visualize the GEDI L4A Aboveground Biomass Density (AGBD) data with lonboard.
import leafmap
leafmap.view_vector(
gdf, color_column="agbd", color_map="Greens", color_k=10, get_radius=25
)