-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_script.py
More file actions
32 lines (24 loc) · 1020 Bytes
/
map_script.py
File metadata and controls
32 lines (24 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import folium
import pandas
import json
df=pandas.read_csv("Volcanoes_USA.txt")
map=folium.Map(location=[df['LAT'].mean(),df['LON'].mean()],zoom_start=4,tiles='Stamen Terrain')
fg=folium.FeatureGroup(name="Volcano Locations")
def color(elev):
minimum=int(min(df['ELEV']))
step=int((max(df['ELEV'])-min(df['ELEV']))/3)
if elev in range(minimum,step):
col='green'
elif elev in range(minimum+step,minimum+step*2):
col='orange'
else:
col='red'
return col
for lat,lon,name,elev in zip(df['LAT'],df['LON'],df['NAME'],df['ELEV']):
fg.add_child(folium.Marker([lat,lon],popup=name,icon=folium.Icon(color=color(elev))))
map.add_child(fg)
map.add_child(folium.GeoJson(json.load(open('worldpopulation.json')),
name='World Population',
style_function=lambda x: {'fillColor':'green' if x['properties']['POP2005']<=10000000 else 'orange' if x['properties']['POP2005']<20000000 else 'red'}))
map.add_child(folium.LayerControl())
map.save(outfile='map.html')