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

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?


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))

@Chepelink I’m not aware of any specific example. The most efficient way to help us help you would be to provide as small complete, minimal reproducer of what you have tried that did not work.

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,

import geopandas as gpd
from 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())

    ("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.patches('xs','ys', source = geosource,fill_color = {'field' :'Range', 'transform' : color_mapper},
          line_color = 'black', line_width = 0.25, fill_alpha = 1)



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?

I included a link to the rar that has the json in my previous answer, or it has to be in another format? Or the link is broken for you?

Kind regards,

No I just missed it earlier. We are in the middle of getting a new release ready but I will take a closer look as soon as I am able.

Oh, cool, that are good news. Thank you very much. Oh, and about the flickering, without the LoD adjustment it does not appear, by the way. Nonetheless, thanks.

@Chepelink the flickering went away for me with some somewhat substantially larger threshold and timeout values:

p.lod_interval = 200
p.lod_timeout = 100 

Thanks, it helped.