module notebookhelper.folium_helper

Short summary

module pyensae.notebookhelper.folium_helper

Module folium does not have any output to a notebook, addresses that issue. The module does not explicitely import folium.

source on GitHub

Functions

function

truncated documentation

folium_embed_map

folium_html_map

Embeds the HTML source of the map directly into the IPython notebook.

Documentation

Module folium does not have any output to a notebook, addresses that issue. The module does not explicitely import folium.

source on GitHub

pyensae.notebookhelper.folium_helper.folium_embed_map(mapf, path='map.html', width='100%', height='510px')[source]
Parameters
  • mapf – folium map

  • path – where to store the temporary map

Returns

HTML (IPython)

Embeds a linked iframe to the map into the IPython notebook.

Note: this method will not capture the source of the map into the notebook. This method should work for all maps (as long as they use relative urls).

Source: folium_base.py

source on GitHub

pyensae.notebookhelper.folium_helper.folium_html_map(mapf, width=None, height=None, asobj=True)[source]

Embeds the HTML source of the map directly into the IPython notebook.

Parameters
  • mapf – folium map

  • width – width

  • height – height

  • asobj – return an object which implements _repr_html_

Returns

HTML (IPython)

This method will not work if the map depends on any files (json data). Also this uses the HTML5 srcdoc attribute, which may not be supported in all browsers.

Source: folium_base.py

Display an inline map with folium in a notebook

import folium
map_osm = folium.Map(location=[48.85, 2.34])
from pyensae.notebook_helper import folium_html_map
map_osm.polygon_marker(location=[48.824338, 2.302641], popup='ENSAE',
                    fill_color='#132b5e', num_sides=3, radius=10)
folium_html_map(map_osm)

With folium version 0.2, this becomes easier:

import folium
map_osm = folium.Map(location=[48.85, 2.34])
from pyensae.notebook_helper import folium_html_map
map_osm.polygon_marker(location=[48.824338, 2.302641], popup='ENSAE',
                    fill_color='#132b5e', num_sides=3, radius=10)
map_osm

Changed in version 1.1: Add parameters width and height to change the size of the map within a notebook. Hopefully, they will be added in folium.

source on GitHub