https://app.dominodatalab.com/r00sj3/jupyter/view/batchdemo.ipynb
In [1]:
%matplotlib inline
import pandas as pd
import folium
from matplotlib.colors import Normalize, rgb2hex
import matplotlib.cm as cm
In [2]:
data = pd.read_csv('http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.csv')
norm = Normalize(data['mag'].min(), data['mag'].max())
map = folium.Map(location=[48, -102], zoom_start=3)
for eq in data.iterrows():
color = rgb2hex(cm.OrRd(norm(float(eq[1]['mag']))))
map.circle_marker([eq[1]['latitude'], eq[1]['longitude']],
popup=eq[1]['place'],
radius=20000*float(eq[1]['mag']),
line_color=color,
fill_color=color)
map.create_map(path='/home/hermantolentino/notebook.epispider.io/public_html/earthquake.html')
# need to replace CDN with https URLs
with open('/home/hermantolentino/notebook.epispider.io/public_html/earthquake.html', 'r') as f:
contents = f.read()
contents = contents.replace("http://cdn.leafletjs.com/leaflet-0.5/", "//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/")
with open('/home/hermantolentino/notebook.epispider.io/public_html/earthquake2.html', 'w') as f:
f.writelines(contents)
In [ ]:
%%HTML
<iframe width="100%" height="450" src="https://notebook.epispider.io/earthquake2.html?inline=true"></iframe>