clstaudt
clstaudt

Reputation: 22438

Fit more folium/leaflet elements on a map

Folium is a great tool to make interactive maps with Python, based on Leaflet.js.

Here I use it to draw a graph on a map.

the_map = folium.Map(tiles="cartodbpositron")
for (u, v) in G.edges():
    if (not bbox) or (in_bbox(u) and in_bbox(v)):
        folium.PolyLine(
            locations=[positions[u][::-1], positions[v][::-1]],
            weight=edge_size_attr[frozenset((u,v))],
            color=get_edge_color(u, v),
            tooltip=get_edge_tooltip(u, v)
        ).add_to(the_map)
return the_map

Works fine. The only problem is that there is a hard limit on the number of edges that can be drawn this way. Above a few hundred, Leaflet seems to go throw in the towel and will not render the map anymore.

Is there something I can do to push the limits and draw a larger number of nodes and edges?

enter image description here

Upvotes: 2

Views: 683

Answers (1)

Marquistador
Marquistador

Reputation: 1951

One potential solution:

jupyter notebook --NotebookApp.iopub_data_rate_limit=<LARGE_NUMBER>

You can allow for a higher iopub rate when you launch jupyter notebook, (@https://github.com/jupyter/notebook/issues/2287 used LARGE_NUMBER==10000000000).

Please proceed with caution, jupyter sets a low limit here in order to avoid crashing your client.

Upvotes: 1

Related Questions