Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d9c81aa
Refactor dasymetric mapping user guide notebook
brendancol Mar 12, 2026
6b00713
Refactor Mahalanobis Distance user guide notebook
brendancol Mar 12, 2026
d453b95
Refactor hydrology user guide notebook
brendancol Mar 12, 2026
b9bac49
Refactor flood analysis user guide notebook
brendancol Mar 12, 2026
699b85a
Refactor fire analysis user guide notebook
brendancol Mar 12, 2026
1967784
Refactor balanced allocation user guide notebook
brendancol Mar 12, 2026
8f2003f
Merge notebook 11 (Hydrology) refactoring
brendancol Mar 12, 2026
27a8eb0
Merge notebook 12 (Flood Analysis) refactoring
brendancol Mar 12, 2026
5cddb8e
Merge notebook 13 (Fire Analysis) refactoring
brendancol Mar 12, 2026
bfc276e
Merge notebook 14 (Dasymetric Mapping) refactoring
brendancol Mar 12, 2026
83ed0bd
Merge notebook 15 (Balanced Allocation) refactoring
brendancol Mar 12, 2026
a02acca
Refactor landform classification user guide notebook
brendancol Mar 12, 2026
dcdb2da
Refactor water indices user guide notebook
brendancol Mar 12, 2026
3a28a94
Refactor diffusion user guide notebook
brendancol Mar 12, 2026
f3fe446
Refactor morphological operators user guide notebook
brendancol Mar 12, 2026
ef26cd5
Refactor bilateral filter user guide notebook
brendancol Mar 12, 2026
2240216
Refactor kriging user guide notebook to match standard structure
brendancol Mar 12, 2026
f362db8
Refactor corridor analysis user guide notebook
brendancol Mar 12, 2026
fb897a1
Refactor hydraulic erosion user guide notebook
brendancol Mar 12, 2026
196eea1
Refactor sky view factor user guide notebook
brendancol Mar 12, 2026
be118bf
Refactor GLCM texture user guide notebook
brendancol Mar 12, 2026
32b1670
Refactor contour lines user guide notebook
brendancol Mar 12, 2026
d0eef6c
Refactor stream analysis user guide notebook
brendancol Mar 12, 2026
aa3acca
Refactor rasterize user guide notebook
brendancol Mar 12, 2026
729eb28
Refactor preview user guide notebook
brendancol Mar 12, 2026
d630660
Refactor zonal crosstab user guide notebook
brendancol Mar 12, 2026
a8f24c9
Refactor viewshed user guide notebook
brendancol Mar 12, 2026
55c29cb
Add execution outputs and preview images for earlier notebooks
brendancol Mar 12, 2026
5e902c8
Remove plt.show() calls from user guide notebooks
brendancol Mar 12, 2026
1cd0d34
Fix matplotlib backend in user guide notebooks
brendancol Mar 12, 2026
9e10a56
Fix rotated sigma ellipses in Mahalanobis notebook
brendancol Mar 12, 2026
96f6d11
Show both original and snapped pour points on watershed plot
brendancol Mar 12, 2026
f164023
Make pour point markers visible on hydrology watershed plots
brendancol Mar 12, 2026
633b5bf
Fix pour point coordinates on hydrology plots
brendancol Mar 12, 2026
b351db0
Add neon flow path visualization to hydrology notebook
brendancol Mar 12, 2026
32a22e5
Re-execute notebooks and fix rasterize scanline off-by-one
brendancol Mar 12, 2026
b72615d
Clear notebook outputs to reduce git bloat
brendancol Mar 12, 2026
e7a9d29
Clean up hydrology notebook plots for legibility
brendancol Mar 13, 2026
e0a71df
Clean up flood analysis plots for legibility
brendancol Mar 13, 2026
d0b5622
Fix contour coordinates to use DataArray coordinate space
brendancol Mar 13, 2026
b72672d
Use generate_terrain in sky view factor notebook, clear all notebook …
brendancol Mar 13, 2026
4aeae0d
Fix dasymetric limiting variable to keep zero-weight pixels uninhabited
brendancol Mar 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions examples/contour_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def draw_contours():
fill_cmap = "gist_earth"
# Use matplotlib's contourf for fills (our contour lines overlay on top)
cf = ax.contourf(
elev_vals, levels=levels_list, cmap=fill_cmap,
origin="lower", alpha=0.35, extend="both",
xs, ys, elev_vals, levels=levels_list, cmap=fill_cmap,
alpha=0.35, extend="both",
)
fill_artists.extend(cf.collections)

Expand Down Expand Up @@ -252,16 +252,24 @@ def update_status():
for spine in ax.spines.values():
spine.set_color("white")

# Map the image extent to the DataArray's coordinate space so that
# contour coordinates (which are in coordinate space) align correctly.
xs = elevation.coords["x"].values
ys = elevation.coords["y"].values
img_extent = [xs[0], xs[-1], ys[0], ys[-1]]

# Hillshade layer
hillshade_img = ax.imshow(
hillshade_vals, cmap="gray", origin="lower",
aspect="equal", interpolation="bilinear", alpha=1.0,
extent=img_extent,
)

# Terrain colour layer
terrain_img = ax.imshow(
elev_vals, cmap="gist_earth", origin="lower",
aspect="equal", interpolation="bilinear", alpha=0.4,
extent=img_extent,
)

# Elevation readout under cursor
Expand All @@ -287,12 +295,18 @@ def update_status():

# -- Event handlers ------------------------------------------------------------

def _coord_to_pixel(xdata, ydata):
"""Convert coordinate-space position to nearest pixel indices."""
col = int(round(np.interp(xdata, xs, np.arange(len(xs)))))
row = int(round(np.interp(ydata, ys, np.arange(len(ys)))))
return row, col


def on_click(event):
"""Left-click: add contour at that elevation. Right-click: remove nearest."""
if event.inaxes != ax:
return
col = int(round(event.xdata))
row = int(round(event.ydata))
row, col = _coord_to_pixel(event.xdata, event.ydata)
if not (0 <= row < GRID_H and 0 <= col < GRID_W):
return

Expand All @@ -304,7 +318,7 @@ def on_click(event):
snapped = round(elev / 10) * 10
if snapped not in custom_levels:
custom_levels.append(snapped)
marker_positions.append((col, row))
marker_positions.append((event.xdata, event.ydata))
print(f" Added contour at elevation {snapped:.0f} "
f"(clicked {elev:.1f} at pixel {row}, {col})")
_update_markers()
Expand Down Expand Up @@ -353,8 +367,7 @@ def on_motion(event):
elev_text.set_text("")
fig.canvas.draw_idle()
return
col = int(round(event.xdata))
row = int(round(event.ydata))
row, col = _coord_to_pixel(event.xdata, event.ydata)
if 0 <= row < GRID_H and 0 <= col < GRID_W:
e = elev_vals[row, col]
elev_text.set_text(f"elev: {e:.1f} m ({row}, {col})")
Expand Down
Loading
Loading