☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Is there an example on how to use LoD on patches?

Community Support
Chepelink
Chepelink

I’m trying to plot 1.8k patches (choropleth) on a map using GeoJSONDataSource. For the most part it renders quickly and nicely. The problem arise when trying to pan or zoom, it is very slow. Now, I read that I can try to solve my problems adjusting the Level of Detail (LoD), but no mater what numbers I use (randomly) on the plot*, it does not seem to have any effect on the map nor panning and zooming speed. Is there an example on how to modify those values for patches?

p=figure(...)
p.lod_factor=X

I also looked into holoview (and geoview) but the slowness is still there. I’m using the html output, Bokeh 2.0.2, and Chrome (Version 83.0.4103.97 (Official Build) (64-bit))

⌁   Link to post
Chepelink
Chepelink

Thank you for your answer. Down is my small complete minimal reproducer, the data is here here for the time being. While doing the SCMR I realised that there were other options aside from lod_factor. Sorry about that. That helped me with the slowness. But, it generated another problem, when zooming in and out, specially in, it flickers, too much, even with lod_timeout at 0. Is there a way to avoid the flickering when zooming, even if it the render is slow?

Kind regards,
C.

import geopandas as gpd
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.models import GeoJSONDataSource,LinearColorMapper
from bokeh.models import HoverTool
from bokeh.tile_providers import CARTODBPOSITRON, get_provider

GeoData= gpd.read_file("test.geojson")
geosource = GeoJSONDataSource(geojson = GeoData.to_json())

TOOLTIPS = [
    ("Value", "@Range")
    ]
tools = 'wheel_zoom,pan,reset'

palette=['#084594', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef']
palette = palette[::-1]
color_mapper = LinearColorMapper(palette = palette, low = 0, high = 4)

p = figure(title = "Test", plot_width=800, 
           plot_height=870, toolbar_location='right', tooltips=TOOLTIPS, tools=tools,
          x_axis_type="mercator", y_axis_type="mercator")
tile_provider = get_provider(CARTODBPOSITRON)
p.add_tile(tile_provider)
p.patches('xs','ys', source = geosource,fill_color = {'field' :'Range', 'transform' : color_mapper},
          line_color = 'black', line_width = 0.25, fill_alpha = 1)

p.lod_factor=8
p.lod_interval=20
p.lod_threshold=5
p.lod_timeout=2

output_file("MyTest.html")
show(p)
⌁   Link to post
Bryan
Bryan

I’m not sure what flicker you are referring to, never having seen it myself. Can you provide the JSON file necessary to run the example so that it can attempt to be redproduced?

⌁   Link to post

End of archived discussion · Replies are disabled