Skip to content

Commit

Permalink
Fix add hyperspectral data bug (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs authored Sep 2, 2024
1 parent 9b75955 commit 80af211
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions leafmap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,31 @@ def on_apply_click(self):

self._host_map.remove(old_layer)

if self._layer_dict["type"] == "LOCAL":
self._host_map.add_raster(
self._filename,
indexes=vis["indexes"],
# Add support for hyperspectral data via HyperCoast
if self._xds is not None:

r_index = self._band_1_dropdown.index
g_index = self._band_2_dropdown.index
b_index = self._band_3_dropdown.index

if (r_index >= g_index and g_index >= b_index) or (
r_index <= g_index and g_index <= b_index
):
pass
else:
sorted_indexes = sorted([r_index, g_index, b_index], reverse=True)
self._band_1_dropdown.index = sorted_indexes[0]
self._band_2_dropdown.index = sorted_indexes[1]
self._band_3_dropdown.index = sorted_indexes[2]
vis["indexes"] = [
self._band_1_dropdown.index + 1,
self._band_2_dropdown.index + 1,
self._band_3_dropdown.index + 1,
]
self._host_map.add_hyper(
self._xds,
dtype=self._layer_dict["hyper"],
wvl_indexes=[index - 1 for index in vis["indexes"]],
colormap=vis["colormap"],
vmin=vis["vmin"],
vmax=vis["vmax"],
Expand All @@ -880,12 +901,11 @@ def on_apply_click(self):
zoom_to_layer=False,
layer_index=layer_index,
)
# Add support for hyperspectral data via HyperCoast
elif self._xds is not None:
self._host_map.add_hyper(
self._xds,
type=self._layer_dict["hyper"],
wvl_indexes=[index - 1 for index in vis["indexes"]],

elif self._layer_dict["type"] == "LOCAL":
self._host_map.add_raster(
self._filename,
indexes=vis["indexes"],
colormap=vis["colormap"],
vmin=vis["vmin"],
vmax=vis["vmax"],
Expand All @@ -895,6 +915,7 @@ def on_apply_click(self):
zoom_to_layer=False,
layer_index=layer_index,
)

elif self._layer_dict["type"] == "COG":
self._host_map.add_cog_layer(
self._layer_dict["url"],
Expand Down

0 comments on commit 80af211

Please sign in to comment.