In [1]:
from bokeh.io import output_notebook, show
from bokeh.models import GeoJSONDataSource, HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.sample_geojson import geojson
import requests

# Notebook output
output_notebook()


Loading BokehJS ...

In [2]:
# From GitHub, a random geojson file; pulling the raw string using requests
r = requests.get('https://raw.githubusercontent.com/codeforamerica/click_that_hood/master/public/data/brazil-states.geojson')

In [4]:
# requests returns bytes, so decode and convert to string
brazilStates = r.content.decode()

# Following Sarah Bird's example from here
geojson = brazilStates

In [6]:
import sys

In [10]:
sys.getsizeof(geojson) / 1e6


Out[10]:
1.995538

In [18]:
geo_source = GeoJSONDataSource(geojson=geojson)

from bokeh.plotting import figure

p = figure(height=900, width=900, lod_threshold=1, lod_factor=10)
p.patches(xs='xs', ys='ys', fill_color = "#EBE02A",fill_alpha=0.7, source=geo_source)

p.multi_line(xs='xs', ys='ys', line_color='white', line_width=0.1, source=geo_source)

# Getting the Hovertool, and adding State name as output
p.add_tools(HoverTool(tooltips=[(
    "State", "@name"
)]))

show(p)


Out[18]:

<Bokeh Notebook handle for In[18]>


In [ ]: