Skip to content

Instantly share code, notes, and snippets.

@betterdatascience
Created December 11, 2020 08:38
Show Gist options
  • Select an option

  • Save betterdatascience/537614084f443fc70149ef9fa774c043 to your computer and use it in GitHub Desktop.

Select an option

Save betterdatascience/537614084f443fc70149ef9fa774c043 to your computer and use it in GitHub Desktop.
005_folium
def generate_color(magnitude):
if magnitude <= 5:
c_outline, c_fill = '#ffda79', '#ffda79'
m_opacity, f_opacity = 0.2, 0.1
else:
c_outline, c_fill = '#c0392b', '#e74c3c'
m_opacity, f_opacity = 1, 1
return c_outline, c_fill, m_opacity, f_opacity
quake_map = folium.Map(
location=[-16.495477, 174.9663341],
zoom_start=5,
tiles='Stamen Terrain',
width=1024,
height=600
)
for _, row in df.iterrows():
c_outline, c_fill, m_opacity, f_opacity = generate_color(row['mag'])
folium.CircleMarker(
location=[row['lat'], row['long']],
color=c_outline,
fill=True,
fillColor=c_fill,
opacity=m_opacity,
fillOpacity=f_opacity,
radius=(row['mag'] ** 2) / 3
).add_to(quake_map)
quake_map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment