Skip to content

Commit

Permalink
Add support for NASA OPERA data products (#1005)
Browse files Browse the repository at this point in the history
* Add support for NASA OPERA data products

* Add support for visualizing raster

* Add DWSx layer options

* Add colormap option

* Error handling for h5

* Add NASA OPERA notebook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add DEM layer

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
giswqs and pre-commit-ci[bot] authored Nov 29, 2024
1 parent 24afac4 commit dca672e
Show file tree
Hide file tree
Showing 6 changed files with 623 additions and 0 deletions.
187 changes: 187 additions & 0 deletions docs/notebooks/101_nasa_opera.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/101_nasa_opera.ipynb)\n",
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/101_nasa_opera.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Searching and Visualizing NASA OPERA Data Products Interactively**\n",
"\n",
"\n",
"Started in April 2021, the Observational Products for End-Users from Remote Sensing Analysis ([OPERA](https://www.jpl.nasa.gov/go/opera)) project at the Jet Propulsion Laboratory collects data from satellite radar and optical instruments to generate six product suites:\n",
"\n",
"* a near-global Surface Water Extent product suite\n",
"* a near-global Surface Disturbance product suite\n",
"* a near-global Radiometric Terrain Corrected product\n",
"* a North America Coregistered Single Look complex product suite\n",
"* a North America Displacement product suite\n",
"* a North America Vertical Land Motion product suite\n",
"\n",
"This notebook demonstrates how to search and visualize NASA OPERA data products interactively using the `leafmap` Python package."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %pip install -U \"leafmap[raster]\" earthaccess"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To download and access the data, you will need to create an Earthdata login. You can register for an account at [urs.earthdata.nasa.gov](https://urs.earthdata.nasa.gov)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"leafmap.nasa_data_login()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[36.1711, -114.6581], zoom=10, height=\"700px\")\n",
"m.add_basemap(\"Satellite\")\n",
"m.add(\"NASA_OPERA\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pan and zoom to your area of interest. Select a dataset from the Short Name dropdown list. Click the \"Search\" button to load the available datasets for the region. The footprints of the datasets will be displayed on the map. Click on a footprint to display the metadata of the dataset. \n",
"\n",
"![image](https://github.com/user-attachments/assets/f3b1b42e-d83d-4f40-b9e6-67082d364367)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The footprints of the datasets can be accessed as a GeoPandas GeoDataFrame:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m._NASA_DATA_GDF.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Select a dataset from the Dataset dropdown list. Then, select a layer from the Layer dropdown list. Choose a appropriate colormap, then click on the \"Display\" button to display the selected layer on the map."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The water classification layer:\n",
"\n",
"![image](https://github.com/user-attachments/assets/f9800913-c683-4a9f-a3b5-164c911a4486)\n",
"\n",
"The DEM layer:\n",
"\n",
"![image](https://github.com/user-attachments/assets/15690881-d259-474f-9c77-eb6c40027ccc)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The selected layer added to the map can be accessed as a xarray Dataset:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m._NASA_DATA_DS"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To save the displayed layer as a GeoTIFF file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m._NASA_DATA_DS[\"band_data\"].rio.to_raster(\"data/DSWx.tif\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To download all the available datasets for the region:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"leafmap.nasa_data_download(m._NASA_DATA_RESULTS[:1], out_dir=\"data\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "geo",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions docs/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
98. Retrieving watershed boundaries from the National Hydrography Dataset (NHD) ([notebook](https://leafmap.org/notebooks/98_watershed))
99. Retrieving wetland boundaries from the National Wetlands Inventory (NWI) ([notebook](https://leafmap.org/notebooks/99_wetlands))
100. Visualizing the National Land Cover Database (NLCD) data products with Leafmap ([notebook](https://leafmap.org/notebooks/100_nlcd))
101. Searching and Visualizing NASA OPERA Data Products Interactively ([notebook](https://leafmap.org/notebooks/101_nasa_opera))

## Demo

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
98. Retrieving watershed boundaries from the National Hydrography Dataset (NHD) ([notebook](https://leafmap.org/notebooks/98_watershed))
99. Retrieving wetland boundaries from the National Wetlands Inventory (NWI) ([notebook](https://leafmap.org/notebooks/99_wetlands))
100. Visualizing the National Land Cover Database (NLCD) data products with Leafmap ([notebook](https://leafmap.org/notebooks/100_nlcd))
101. Searching and Visualizing NASA OPERA Data Products Interactively ([notebook](https://leafmap.org/notebooks/101_nasa_opera))

## Demo

Expand Down
4 changes: 4 additions & 0 deletions leafmap/leafmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def add(self, obj, index=None, **kwargs) -> None:
from .toolbar import nasa_data_gui

nasa_data_gui(self, **kwargs)
elif obj == "NASA_OPERA":
from .toolbar import nasa_opera_gui

nasa_opera_gui(self, **kwargs)
elif obj == "inspector":
from .toolbar import inspector_gui

Expand Down
Loading

0 comments on commit dca672e

Please sign in to comment.