-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.py
33 lines (25 loc) · 1014 Bytes
/
map.py
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
33
import folium
import pandas
data=pandas.read_csv("Mass.csv")
lat=list(data["LATITUDE"])
lon=list(data["LONGITUDE"])
case=list(data["CASE"])
fat=list(data["FATALITIES"])
def color_producer(fatal):
if fatal<10:
return 'darkblue'
elif 10<fatal<20:
return 'orange'
else:
return 'red'
map=folium.Map(location=[38.58,-99.09],zoom_start=6,tiles='OpenStreetMap')
fgm=folium.FeatureGroup(name="Mass Killings")
for lt,ln,nm,ft in zip(lat,lon,case,fat):
fgm.add_child(folium.CircleMarker(location=[lt,ln],radius=10,popup=str(nm),fill_color=color_producer(ft),color='grey',fill_opacity=0.7))
fgp=folium.FeatureGroup(name="Population")
fgp.add_child(folium.GeoJson(data=open("world.json",'r',encoding='utf-8-sig').read(),style_function=lambda x:{'fillColor':'green' if x['properties']['POP2005']<10000000
else 'orange' if 10000000<=x['properties']['POP2005']< 20000000 else 'red'}))
map.add_child(fgm)
map.add_child(fgp)
map.add_child(folium.LayerControl())
map.save("Map.html")