gee-community/geemap

Customizing legend seems to have no effect

jportolese opened this issue · 2 comments

Mon Apr 24 23:02:13 2023 Eastern Daylight Time

OS | Windows | CPU(s) | 20 | Machine | AMD64
Architecture | 64bit | RAM | 63.9 GiB | Environment | Jupyter
Python 3.8.16 (default, Jan 17 2023, 22:25:28) [MSC v.1916 64 bit (AMD64)]
geemap | 0.20.4 | ee | 0.1.339 | ipyleaflet | 0.17.2
folium | 0.13.0 | jupyterlab | 3.5.3 | notebook | 6.5.2
ipyevents | 2.0.1 | geopandas | 0.12.2 |   |  
Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture a

Description

Running the unsupervised classification tutorial and tried to make a change to the colors and the legend entries to replace the "one, two, three, four, etc" and it seems to ignore the updates and continues to show the standard legend.

Ran the following code:

legend_classes = ['Urban1', 'Urban2', 'Veg1', 'Veg2', 'Water']
legend_cols = ['#595959', '#d9d9d9', '#004d1a', '#00cc44', '#0066ff']

# Reclassify the map
result = result.remap([0, 1, 2, 3, 4], [1, 2, 3, 4, 5])

Map=geemap.Map()
Map.centerObject(point, 12)

Map.addLayer(
    result, {'min': 1, 'max': 5, 'palette': legend_cols},  'Labelled clusters'
)
Map.add_legend(
    legend_keys=legend_classes, legend_colors=legend_cols, position='bottomright'
)
Map

Screenshot 2023-04-24 230752

giswqs commented

The parameter names have changed. It should be labels and colors instead of legend_keys and legend_colors.

https://geemap.org/geemap/#geemap.geemap.Map.add_legend