Skip to content

Commit

Permalink
Add support for visualizing DESIS hyperspectral data (#38)
Browse files Browse the repository at this point in the history
* Add support for visualizing DISES data

* Add DESIS module to docs

* Add wavelength info to dataset

* Add DESIS spectral signature

* Add DESIS notebook example

* Add DESIS notebook to docs

* Add ECOSTRESS to docs

* Fix typo
  • Loading branch information
giswqs authored Jun 4, 2024
1 parent 0f59737 commit 971ab39
Show file tree
Hide file tree
Showing 9 changed files with 524 additions and 40 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@

## Features

- Interactive visualization and analysis of hyperspectral data (e.g., [EMIT](https://earth.jpl.nasa.gov/emit), [PACE](https://pace.gsfc.nasa.gov))
- Interactive visualization and analysis of hyperspectral data (e.g., [EMIT](https://earth.jpl.nasa.gov/emit), [PACE](https://pace.gsfc.nasa.gov), [DESIS](https://www.earthdata.nasa.gov/s3fs-public/imported/DESIS_TCloud_Mar0421.pdf))
- Interactive visualization of NASA [ECOSTRESS](https://ecostress.jpl.nasa.gov) data
- Interactive extraction and visualization of spectral signatures
- Saving spectral signatures as CSV files

## Demos

- Visualizing NASA [EMIT](https://earth.jpl.nasa.gov/emit) data interactively
- Visualizing NASA [EMIT](https://earth.jpl.nasa.gov/emit) hyperspectral data interactively

![](https://i.imgur.com/zeyABMq.gif)

- Visualizing NASA [PACE](https://pace.gsfc.nasa.gov) data interactively
- Visualizing NASA [PACE](https://pace.gsfc.nasa.gov) hyperspectral data interactively

![](https://i.imgur.com/HBMjW6o.gif)

- Visualizing [DESIS](https://www.earthdata.nasa.gov/s3fs-public/imported/DESIS_TCloud_Mar0421.pdf) hyperspectral data interactively

![](https://i.imgur.com/PkwOPN5.gif)

## Acknowledgement

This projects draws inspiration and adapts source code from the [nasa/EMIT-Data-Resources](https://github.com/nasa/EMIT-Data-Resources) repository. Credit goes to the original authors.
3 changes: 3 additions & 0 deletions docs/desis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# desis module

::: hypercoast.desis
151 changes: 151 additions & 0 deletions docs/examples/desis.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/HyperCoast/blob/main/docs/examples/desis.ipynb)\n",
"\n",
"# Visualizing DESIS data interactively with HyperCoast\n",
"\n",
"This notebook demonstrates how to visualize [DESIS](https://www.earthdata.nasa.gov/s3fs-public/imported/DESIS_TCloud_Mar0421.pdf) hyperspectral data interactively with HyperCoast."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %pip install \"hypercoast[extra]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import hypercoast"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = \"https://github.com/opengeos/datasets/releases/download/hypercoast/desis.tif\"\n",
"filepath = \"data/desis.tif\"\n",
"hypercoast.download_file(url, filepath)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Load the dataset as a xarray.Dataset object."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset = hypercoast.read_desis(filepath)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the spectral signature of a pixel."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"hypercoast.filter_desis(dataset, lat=29.4315, lon=91.2927, return_plot=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Visualize a single band of the hyperspectral image."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = hypercoast.Map()\n",
"m.add_basemap(\"Hybrid\")\n",
"m.add_desis(filepath, bands=[200], vmin=0, vmax=5000, nodata=0, colormap=\"jet\")\n",
"m.add_colormap(cmap=\"jet\", vmin=0, vmax=0.5, label=\"Reflectance\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/owUtN8T.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the spectral signature of a pixel interactively."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = hypercoast.Map()\n",
"m.add_basemap(\"Hybrid\")\n",
"m.add_desis(filepath, bands=[50, 100, 200], vmin=0, vmax=1000, nodata=0)\n",
"m.add(\"spectral\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/PkwOPN5.gif)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "hyper",
"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.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
11 changes: 8 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@

## Features

- Interactive visualization and analysis of hyperspectral data (e.g., [EMIT](https://earth.jpl.nasa.gov/emit), [PACE](https://pace.gsfc.nasa.gov))
- Interactive visualization and analysis of hyperspectral data (e.g., [EMIT](https://earth.jpl.nasa.gov/emit), [PACE](https://pace.gsfc.nasa.gov), [DESIS](https://www.earthdata.nasa.gov/s3fs-public/imported/DESIS_TCloud_Mar0421.pdf))
- Interactive visualization of NASA [ECOSTRESS](https://ecostress.jpl.nasa.gov) data
- Interactive extraction and visualization of spectral signatures
- Saving spectral signatures as CSV files

## Demos

- Visualizing NASA [EMIT](https://earth.jpl.nasa.gov/emit) data interactively
- Visualizing NASA [EMIT](https://earth.jpl.nasa.gov/emit) hyperspectral data interactively

![](https://i.imgur.com/zeyABMq.gif)

- Visualizing NASA [PACE](https://pace.gsfc.nasa.gov) data interactively
- Visualizing NASA [PACE](https://pace.gsfc.nasa.gov) hyperspectral data interactively

![](https://i.imgur.com/HBMjW6o.gif)

- Visualizing [DESIS](https://www.earthdata.nasa.gov/s3fs-public/imported/DESIS_TCloud_Mar0421.pdf) hyperspectral data interactively

![](https://i.imgur.com/PkwOPN5.gif)

## Acknowledgement

This projects draws inspiration and adapts source code from the [nasa/EMIT-Data-Resources](https://github.com/nasa/EMIT-Data-Resources) repository. Credit goes to the original authors.
43 changes: 37 additions & 6 deletions hypercoast/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,10 @@ def download_pace(
Args:
granules (List[dict]): The granules to download.
out_dir (str, optional): The output directory where the granules will be downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading. Defaults to 8.
out_dir (str, optional): The output directory where the granules will be
downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading.
Defaults to 8.
"""

download_nasa_data(granules=granules, out_dir=out_dir, threads=threads)
Expand All @@ -350,8 +352,10 @@ def download_emit(
Args:
granules (List[dict]): The granules to download.
out_dir (str, optional): The output directory where the granules will be downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading. Defaults to 8.
out_dir (str, optional): The output directory where the granules will be
downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading.
Defaults to 8.
"""

download_nasa_data(granules=granules, out_dir=out_dir, threads=threads)
Expand All @@ -366,8 +370,10 @@ def download_ecostress(
Args:
granules (List[dict]): The granules to download.
out_dir (str, optional): The output directory where the granules will be downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading. Defaults to 8.
out_dir (str, optional): The output directory where the granules will be
downloaded. Defaults to None (current directory).
threads (int, optional): The number of threads to use for downloading.
Defaults to 8.
"""

download_nasa_data(granules=granules, out_dir=out_dir, threads=threads)
Expand All @@ -382,3 +388,28 @@ def nasa_earth_login(strategy: str = "all", persist: bool = True, **kwargs) -> N
"""

leafmap.nasa_data_login(strategy=strategy, persist=persist, **kwargs)


def convert_coords(
coords: List[Tuple[float, float]], from_epsg: str, to_epsg: str
) -> List[Tuple[float, float]]:
"""
Convert a list of coordinates from one EPSG to another.
Args:
coords: List of tuples containing coordinates in the format (latitude, longitude).
from_epsg: Source EPSG code (default is "epsg:4326").
to_epsg: Target EPSG code (default is "epsg:32615").
Returns:
List of tuples containing converted coordinates in the format (x, y).
"""
import pyproj

# Define the coordinate transformation
transformer = pyproj.Transformer.from_crs(from_epsg, to_epsg, always_xy=True)

# Convert each coordinate
converted_coords = [transformer.transform(lon, lat) for lat, lon in coords]

return converted_coords
Loading

0 comments on commit 971ab39

Please sign in to comment.