lonboard icon indicating copy to clipboard operation
lonboard copied to clipboard

[BUG] H3 layers are not fully rendered in Map when layer is swapped

Open hamilton-earthscope opened this issue 1 month ago • 1 comments

Context

When i use ScatterPlotLayers in my Map, i can dynamically replace the layers and the map redraws as expected.

https://github.com/user-attachments/assets/70122b1a-41e9-483c-970c-43d691c80440

However, when I use H3HexagonLayer and try to do the same thing, the map never fully redraws until i pan or zoom the map. The outlines of the hexagons are being drawn.

https://github.com/user-attachments/assets/51e6c247-2983-43f7-9aa9-1ccb9baefb2d

Resulting behaviour, error message or logs

No logs/warnings/errors.

Environment

  • OS: Mac Sequoia 15.6.1
  • Browser: VSCode/Cursor using IPython.display
  • Python 3.13.5
  • Lonboard Version: [e.g. 0.13.0]

Steps to reproduce the bug

  1. build h3 hexagon layers that i can dynamically switch between with a slider widget
  2. create map and set first h3 layer (doesn't render fully until panning/zooming)
  3. on slider change, dynamically replace the map's layer with pre-computed layer

For clarity, when I say "replace the map's layer" I mean:

map_widget = Map(...)
slider = widgets.IntSlider(...)

def on_slider_change(change):
    current_minute_idx = change["new"]
    new_layer = bin_layers[current_minute_idx]
    map_widget.layers = [new_layer]

slider.observe(on_slider_change, names="value")

I'm creating the layers as follows

bin_layers = {}
for ... in range(...):
    colors = ...

    # Create H3 layer
    layer = H3HexagonLayer(layer_table, get_hexagon=layer_table.column("h3_index"))
    layer.get_fill_color = colors

hamilton-earthscope avatar Nov 12 '25 17:11 hamilton-earthscope

Actually, if I enable high_precision (docs) then the rendering works as expected on change, but it is much less performant.

hamilton-earthscope avatar Nov 12 '25 17:11 hamilton-earthscope

I think this is likely related to https://github.com/developmentseed/lonboard/issues/994.

I think the core is a mismatch between the Jupyter/widget state and the deck.gl state. Because as you see in the map, it renders correctly once you pan the map a little.

I agree this is a bug but not 100% sure yet how to solve it.

Perhaps I need to experiment with updateTriggers here.

Do you happen to have a fully reproducible example?

kylebarron avatar Nov 17 '25 20:11 kylebarron

Interestingly, if I use a coarser resolution for my h3 cells, then it works as expected. Seems like the issue appears with h3 resolution >=6.

Anyways, try out the dataset and notebook below

lonboard_h3_repro.parquet.zip

repro.ipynb

hamilton-earthscope avatar Nov 18 '25 15:11 hamilton-earthscope