Skip to content

Commit

Permalink
Improve NASA OPERA colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Dec 14, 2024
1 parent f6384cb commit b1cff57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/notebooks/103_raster_colormap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"outputs": [],
"source": [
"import leafmap\n",
"import rioxarray as rxr"
"import rioxarray as rxr\n",
"from leafmap.common import get_image_colormap"
]
},
{
Expand Down Expand Up @@ -87,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"colormap = leafmap.get_image_colormap(filepath)"
"colormap = get_image_colormap(filepath)"
]
},
{
Expand Down
10 changes: 7 additions & 3 deletions leafmap/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6789,7 +6789,7 @@ def get_temp_creds():

palette = widgets.Dropdown(
options=cmap_options,
value="tab10",
value=None,
description="Colormap:",
style=style,
layout=widgets.Layout(width="200px", padding=padding),
Expand Down Expand Up @@ -6979,7 +6979,11 @@ def button_clicked(change):
da = ds["band_data"]
nodata = os.environ.get("NODATA", 0)
da = da.fillna(nodata)
image = array_to_image(da)
try:
colormap = get_image_colormap(ds)
except Exception as e:
colormap = None
image = array_to_image(da, colormap=colormap)
setattr(m, "_NASA_DATA_IMAGE", image)
name_prefix = layer.value.split(".")[0]
items = dataset.value.split("_")
Expand Down Expand Up @@ -7013,7 +7017,7 @@ def button_clicked(change):
dataset.value = None
layer.options = []
layer.value = None
palette.value = "tab10"
palette.value = None
output.clear_output()

if "Footprints" in m.get_layer_names():
Expand Down

0 comments on commit b1cff57

Please sign in to comment.