Magic to embed maps in notebooks

57 views
Skip to first unread message

Tony Hirst

unread,
Dec 10, 2017, 1:19:28 PM12/10/17
to Project Jupyter
Whilst trying to show folk how easy it was to embed interactive maps in notebooks using things like folium, I kept getting the response that it still required code familiarity which would be a blocker to some. So I wondered whether magic might be a way to try to simplify it.



--tony

Lawrence D’Oliveiro

unread,
Dec 10, 2017, 11:37:47 PM12/10/17
to Project Jupyter
On Monday, December 11, 2017 at 7:19:28 AM UTC+13, Tony Hirst wrote:
Whilst trying to show folk how easy it was to embed interactive maps in notebooks using things like folium, I kept getting the response that it still required code familiarity which would be a blocker to some. So I wondered whether magic might be a way to try to simplify it.



Cool. Can you have other stuff in the same cell? E.g.

    ... stuff before ...
    %folium ...
   ... stuff after ...

If not, let me suggest making it a cell magic rather than a line magic. Then you can also use the rest of the cell contents for purposes such as adding overlays.

Tim Head

unread,
Dec 11, 2017, 4:47:22 AM12/11/17
to jup...@googlegroups.com
On Mon, Dec 11, 2017 at 5:37 AM Lawrence D’Oliveiro <lawren...@gmail.com> wrote:
On Monday, December 11, 2017 at 7:19:28 AM UTC+13, Tony Hirst wrote:
Whilst trying to show folk how easy it was to embed interactive maps in notebooks using things like folium, I kept getting the response that it still required code familiarity which would be a blocker to some. So I wondered whether magic might be a way to try to simplify it.

Take a look at what nteract did with GeoJSON rendering: https://github.com/nteract/nteract/#overview I've not used it for "real" but it looks quite nice for "let me see what this will look like". Maybe someone knows how well this mimetype is rendered in jupyter notebook/lab?

T

Tony Hirst

unread,
Dec 12, 2017, 8:46:13 AM12/12/17
to Project Jupyter
@Lawrence

Yeah, I was wondering that... I guess it could return the map object to let you play with it, or pass a map object into it, which would let you build up layers/
Re: cell magic, I wasn't clear in my own mind how that would work any simpler than just writing py/folium statements?

@Tim

I keep forgetting to look to nteract... thx for reminder

--tony

Tony Hirst

unread,
Dec 12, 2017, 9:18:15 AM12/12/17
to Project Jupyter
Okay - added layering - pass a map in as a variable name  pointing to a map in the -b argument:

x = %folium_map -m 52.0250,-0.7084,"My marker"
%folium_map -b x -m 52.02,-0.708,"My other marker"
Reply all
Reply to author
Forward
0 new messages