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

**URL:** <https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965>\
**Category:** General Usage\
**Created:** [August 25, 2019, 4:53pm UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965 "2019-08-25T16:53:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [August 25, 2019, 4:53pm UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/1 "2019-08-25T16:53:14Z")

</div>

I’m reading the tutorial following this link: [OpenStreetMapX\_tutorial](https://pszufe.github.io/OpenStreetMapX_Tutorial/)  
More specifically, the code I’m running is the following:

```julia
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
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.

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [August 25, 2019, 8:26pm UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/2 "2019-08-25T20:26:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [August 26, 2019, 10:29am UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/3 "2019-08-26T10:29:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [August 26, 2019, 10:37am UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/4 "2019-08-26T10:37:22Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [August 26, 2019, 11:37am UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/5 "2019-08-26T11:37:48Z")

</div>

Yes. It works. Thank you for quick reply.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [August 26, 2019, 12:46pm UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/6 "2019-08-26T12:46:17Z")

</div>

@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!

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [August 26, 2019, 1:45pm UTC](https://discourse.julialang.org/t/how-to-draw-a-folium-folium-map-object-using-pycall-and-julia/27965/7 "2019-08-26T13:45:30Z")

</div>

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