How to draw a folium.folium.Map object using pycall and Julia?

I’m reading the tutorial following this link: https://pszufe.github.io/OpenStreetMapX_Tutorial/
More specifically, the code I’m running is the following:

using PyCall
flm = pyimport("folium")
matplotlib_cm = pyimport("matplotlib.cm")
matplotlib_colors = pyimport("matplotlib.colors")

cmap = matplotlib_cm.get_cmap("prism")

SHOW_PATHS=20
m = flm.Map()
for k=1:min(SHOW_PATHS, length(routes))
    locs = [LLA(mx.nodes[n],mx.bounds) for n in routes[k]]
    info = "Sample route number $k\n<BR>"*
        "Length: $(length(routes[k])) nodes\n<br>" *
        "From: $(routes[k][1]) $(round.((locs[1].lat, locs[1].lon),digits=4))\n<br>" *
        "To: $(routes[k][end]) $(round.((locs[end].lat, locs[end].lon),digits=4))"
    flm.PolyLine(        
        [(loc.lat, loc.lon) for loc in locs ],
        popup=info,
        tooltip=info,
        color=matplotlib_colors.to_hex(cmap(k/SHOW_PATHS))       
    ).add_to(m)
end

MAP_BOUNDS = [(mx.bounds.min_y,mx.bounds.min_x),(mx.bounds.max_y,mx.bounds.max_x)]
flm.Rectangle(MAP_BOUNDS, color="black",weight=6).add_to(m)
m.fit_bounds(MAP_BOUNDS)

In the tutorial, Jupiter is used. That’s why the map is drawn directly with a simple line calling the object m. I’m using Julia REPL. When I was trying to show the object m through REPL, the following is the output.

julia> m
PyObject <folium.folium.Map object at 0x7fe364b8c9b0>

So, I was wondering, how to draw this m folium.folium.Map object? Any comments are greatly appreciated.

you could try m.save("index.html") and then look at the html.
Alternatively you could install IJulia and run it in Jupyter (as the tutorial does).
I think I did run this in VS code successfully too.
I have not done any plotting in the REPL for a while. Do ‘normal’ plots work in the REPL for you?

1 Like

I have also not done many plotting in the REPL. I’m not sure what do you mean by ‘normal’ plots in REPL…

Does this work in your repl?
This is what I mean with a normal plot

using Plots
x = 1:10; y = rand(10); # These are the plotting data
plot(x,y)

Yes. It works. Thank you for quick reply.

@bernhard, I just tried the m.save("index.html") and checked out the file index.html. It works very well. Although it is not exactly what I intended to have, thank you so much!

@bernhard, moreover, do you happen to know what is exactly the purpose of m.fit_bounds(MAP_BOUNDS) in the above code? Many thanks.