You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating System: Linux 4.15.0-136-generic x86_64 x86_64 x86_64 GNU/Linux
Description
I processed some data, then added two layers to a geemap.Map with a custom palette. I clicked on the settings button on one layer and got an error. I expected to change some settings (e.g. add the colorbar to the map).
What I Did
# simple demo to get max NDVI layer (no atm correction)
import ee
import datetime
import math
ee.Initialize()
date_str='2017-04-01'
lonlat=[38.530867, 30.236383]
date = ee.Date(date_str)
geom = ee.Geometry.Point(lonlat[0], lonlat[1]) # lon/lat
# Demo: only 10 days - few images
S2_2017 = ee.ImageCollection('COPERNICUS/S2').filterBounds(geom).filterDate(date,date.advance(10,'day')).sort('system:time_start')
def compute_ndvi(image):
toa = image.divide(10000.)
ndvi = toa.normalizedDifference(['B8','B4'])
return ndvi
# map the compute_ndvi function to the collection:
ndvi_collection = S2_2017.map(compute_ndvi)
# Reduce the collection to get maximum and stdDev:
max_ndvi=ndvi_collection.reduce(ee.Reducer.max())
std_ndvi=ndvi_collection.reduce(ee.Reducer.stdDev())
# and add them to a geemap
import geemap
Map=geemap.Map(center=[lonlat[1], lonlat[0]], zoom=10) #lat/lon
ndvi_viz = {
'min':0,
'max':1,
'palette':["#d7191c","fdae61","#ffffc0","#a6d96a","#1a9641"]
}
Map.addLayer(std_ndvi, ndvi_viz, 'Standard deviation NDVI', True, 1)
Map.addLayer(max_ndvi, ndvi_viz, 'Max NDVI', True, 1)
Map
Here is the error that I got:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in _handle_msg(self, msg)
674 if 'buffer_paths' in data:
675 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 676 self.set_state(state)
677
678 # Handle a state request.
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in set_state(self, sync_data)
543 from_json = self.trait_metadata(name, 'from_json',
544 self._trait_from_json)
--> 545 self.set_trait(name, from_json(sync_data[name], self))
546
547 def send(self, content, buffers=None):
~/.conda/envs/gee-ksa/lib/python3.9/contextlib.py in __exit__(self, type, value, traceback)
122 if type is None:
123 try:
--> 124 next(self.gen)
125 except StopIteration:
126 return False
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/traitlets/traitlets.py in hold_trait_notifications(self)
1212 for changes in cache.values():
1213 for change in changes:
-> 1214 self.notify_change(change)
1215
1216 def _notify_trait(self, name, old_value, new_value):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in notify_change(self, change)
604 # Send new state to front-end
605 self.send_state(key=name)
--> 606 super(Widget, self).notify_change(change)
607
608 def __repr__(self):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/traitlets/traitlets.py in notify_change(self, change)
1225 def notify_change(self, change):
1226 """Notify observers of a change event"""
-> 1227 return self._notify_observers(change)
1228
1229 def _notify_observers(self, event):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/traitlets/traitlets.py in _notify_observers(self, event)
1262 c = getattr(self, c.name)
1263
-> 1264 c(event)
1265
1266 def _add_notifiers(self, handler, name, type):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/geemap/geemap.py in layer_vis_on_click(change)
955 if self.vis_widget is not None:
956 self.vis_widget = None
--> 957 self.vis_widget = self.create_vis_widget(layer_dict)
958 if self.vis_control in self.controls:
959 self.remove_control(self.vis_control)
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/geemap/geemap.py in create_vis_widget(self, layer_dict)
3681 if len(palette.value) > 0 and "," in palette.value:
3682 colors = ["#" + color.strip() for color in palette.value.split(",")]
-> 3683 colorbar = cmap.LinearColormap(
3684 colors=colors,
3685 vmin=value_range.value[0],
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/branca/colormap.py in __init__(self, colors, index, vmin, vmax, caption)
194 else:
195 self.index = list(index)
--> 196 self.colors = [_parse_color(x) for x in colors]
197
198 def rgba_floats_tuple(self, x):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/branca/colormap.py in <listcomp>(.0)
194 else:
195 self.index = list(index)
--> 196 self.colors = [_parse_color(x) for x in colors]
197
198 def rgba_floats_tuple(self, x):
~/.conda/envs/gee-ksa/lib/python3.9/site-packages/branca/colormap.py in _parse_color(x)
43 cname = _cnames.get(x.lower(), None)
44 if cname is None:
---> 45 raise ValueError('Unknown color {!r}.'.format(cname))
46 color_tuple = _parse_hex(cname)
47 else:
ValueError: Unknown color None.
Here are two screenshots of the map:
The text was updated successfully, but these errors were encountered:
The "#" in your hex color code caused the problem. I just committed code to fix the bug. Update the package using geemap.update_package() and try again.
Environment Information
Description
I processed some data, then added two layers to a geemap.Map with a custom palette. I clicked on the settings button on one layer and got an error. I expected to change some settings (e.g. add the colorbar to the map).
What I Did
Here is the error that I got:
Here are two screenshots of the map:
The text was updated successfully, but these errors were encountered: