Skip to content

grass.jupyter: Add legend support to InteractiveMap (#5468)#7072

Open
saurabh12nxf wants to merge 5 commits intoOSGeo:mainfrom
saurabh12nxf:legend-feature-5468
Open

grass.jupyter: Add legend support to InteractiveMap (#5468)#7072
saurabh12nxf wants to merge 5 commits intoOSGeo:mainfrom
saurabh12nxf:legend-feature-5468

Conversation

@saurabh12nxf
Copy link
Contributor

Added raster legend support to grass.jupyter.InteractiveMap as requested in #5468.

Changes

  • Created legend.py module with parse_colors() and generate_legend_html()
  • Added add_legend() method to InteractiveMap class
  • Supports both folium and ipyleaflet backends
  • Automatically detects categorical vs continuous rasters
  • Professional CSS styling matching Leaflet native controls

Usage

import grass.jupyter as gj

m = gj.InteractiveMap()
m.add_raster("elevation")
m.add_legend("elevation", title="Elevation (m)")
m.show()

Note : Tested parse_colors() with r.colors.out (elevation, landclass96), verified HTML generation and legend attachment logic for both backends; full end-to-end testing not possible locally due to ReprojectionRenderer initialization issues in WSL/OSGeo4W (unrelated to legend code); requesting CI validation for complete integration testing.

@github-actions github-actions bot added Python Related code is in Python libraries notebook labels Feb 11, 2026
)
self.map.add(legend_control)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ruff] reported by reviewdog 🐶

Suggested change

@petrasovaa
Copy link
Contributor

Please include one or more screenshots, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries notebook Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants