Visualizing Spectral Data from Field Measurements¶
This notebook demonstrates how to visualize spectral data from field measurements.
In [1]:
Copied!
# %pip install "hypercoast[extra]"
# %pip install "hypercoast[extra]"
In [2]:
Copied!
import hypercoast
import pandas as pd
import hypercoast
import pandas as pd
Download a sample dataset.
In [3]:
Copied!
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/pace_sample_points.csv"
data = pd.read_csv(url)
data.head()
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/pace_sample_points.csv"
data = pd.read_csv(url)
data.head()
Out[3]:
band | wavelength | (30.1926 -90.1318) | (30.1594 -90.2856) | (29.3295 -92.3071) | (28.8783 -90.4559) | (30.5481 -87.9840) | (29.5305 -85.0671) | (28.8254 -85.6659) | (29.4587 -83.8477) | (26.8878 -87.7643) | (24.6570 -86.4954) | (26.8045 -82.4854) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 339.0 | NaN | NaN | 0.000100 | NaN | NaN | NaN | NaN | NaN | 0.001718 | 0.000710 | NaN |
1 | 1 | 341.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.001554 | 0.000846 | NaN |
2 | 2 | 344.0 | NaN | NaN | 0.001816 | NaN | NaN | NaN | NaN | NaN | 0.004047 | 0.003598 | NaN |
3 | 3 | 346.0 | 0.000346 | NaN | 0.002393 | NaN | NaN | NaN | NaN | NaN | 0.005045 | 0.004646 | NaN |
4 | 4 | 348.0 | NaN | NaN | 0.001578 | NaN | NaN | NaN | NaN | NaN | 0.004258 | 0.003984 | NaN |
Download PACE data.
In [4]:
Copied!
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
filepath = "data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
hypercoast.download_file(url, filepath)
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
filepath = "data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
hypercoast.download_file(url, filepath)
data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc already exists. Skip downloading. Set overwrite=True to overwrite.
Out[4]:
'/home/runner/work/HyperCoast/HyperCoast/docs/examples/data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc'
Read the PACE dataset.
In [5]:
Copied!
dataset = hypercoast.read_pace(filepath)
dataset = hypercoast.read_pace(filepath)
Run the following cell to show the map. Click on the markers to see the spectral data.
In [6]:
Copied!
m = hypercoast.Map(center=[27.235094, -87.791748], zoom=6)
m.add_basemap("Hybrid")
wavelengths = [450, 550, 650]
m.add_pace(
dataset, wavelengths, indexes=[3, 2, 1], vmin=0, vmax=0.02, layer_name="PACE"
)
m.add("spectral")
m.add_field_data(
data,
x_col="wavelength",
y_col_prefix="(",
x_label="Wavelength (nm)",
y_label="Reflectance",
use_marker_cluster=True,
)
m.set_center(-87.791748, 27.235094, zoom=6)
m
m = hypercoast.Map(center=[27.235094, -87.791748], zoom=6)
m.add_basemap("Hybrid")
wavelengths = [450, 550, 650]
m.add_pace(
dataset, wavelengths, indexes=[3, 2, 1], vmin=0, vmax=0.02, layer_name="PACE"
)
m.add("spectral")
m.add_field_data(
data,
x_col="wavelength",
y_col_prefix="(",
x_label="Wavelength (nm)",
y_label="Reflectance",
use_marker_cluster=True,
)
m.set_center(-87.791748, 27.235094, zoom=6)
m
Out[6]: