Skip to content

grass.jupyter: Add profile tool to gj.InteractiveMap - #8037

Open
cwhite911 wants to merge 2 commits into
OSGeo:mainfrom
cwhite911:grass-jupyter-profile
Open

cwhite911 wants to merge 2 commits into
OSGeo:mainfrom
cwhite911:grass-jupyter-profile

Conversation

@cwhite911

Copy link
Copy Markdown
Contributor

Description

Adds a raster profile tool to grass.jupyter.

gj.Profile samples one or more rasters along a line with r.profile and returns the data. Its figure has a map panel with the line and numbered vertices, and a chart with matching markers. Nulls become gaps in the line.

Motivation and context

The only profile UI in GRASS is in the wxGUI. d.profile draws a single raster transect as an image and returns no data. In a notebook there was no way to draw a line on the map and get the values back, or to produce a figure showing where along the line each value comes from.

Examples

profile = gj.Profile(["elevation", "elev_lid792_1m"], [(638000, 220000), (640000, 222000)])
profile.data["elevation"][:2]
# [{'easting': 638000.0, 'northing': 220000.0, 'distance': 0, 'value': 109.4}, ...]
profile.vertices        # [{'easting': ..., 'northing': ..., 'distance': ...}, ...]
profile.to_dataframe()  # optional, needs pandas
profile.show()
profile.save("profile.png")
Screenshot 2026-10-08 at 8 30 20 PM `InteractiveMap` gets a profile button (ipyleaflet backend). Draw a line, pick the rasters, and the figure appears below the map:
m = gj.InteractiveMap()
m.add_raster("elevation")
m.show()
# after drawing a line with the profile tool:
m.profile.data
m.profile.save("profile.png")
Screenshot 2026-10-08 at 8 30 01 PM

Behavior Change

ipyleaflet, InteractiveMap.show() returns a VBox with the map and an output area below it, instead of the bare ipyleaflet.Map. The map widget is still InteractiveMap.map. Folium is unchanged.

Parts of profile.py were written with AI assistance and reviewed by me.

AI Assisted

@cwhite911 cwhite911 self-assigned this Oct 9, 2026
@github-actions github-actions Bot added Python Related code is in Python libraries docs tests Related to Test Suite notebook labels Oct 9, 2026
@cwhite911
cwhite911 requested a review from petrasovaa October 13, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libraries notebook Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant