Skip to content

Instantly share code, notes, and snippets.

@vpipkt
Last active April 29, 2016 13:04
Show Gist options
  • Save vpipkt/778b6bfb50a6a141e7bcf610ea49b7f1 to your computer and use it in GitHub Desktop.
Save vpipkt/778b6bfb50a6a141e7bcf610ea49b7f1 to your computer and use it in GitHub Desktop.
import pandas as pd
import folium
from matplotlib.colors import Normalize, rgb2hex
import matplotlib.cm as cm
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']))))
marker = folium.CircleMarker([eq[1]['latitude'], eq[1]['longitude']],
popup=eq[1]['place'],
radius=20000*float(eq[1]['mag']),
color=color,
fill_color=color)
map.add_children(marker)
map
@vpipkt
Copy link
Author

vpipkt commented Apr 29, 2016

This will work and produce an inline map in jupyter notebook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment