-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap2.py
More file actions
33 lines (28 loc) · 1.23 KB
/
map2.py
File metadata and controls
33 lines (28 loc) · 1.23 KB
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 pandas
import folium
import numpy
file = pandas.read_csv("Volcanoes.txt")
lat=list(file.LAT)
lon=list(file.LON)
elev = list(file["ELEV"])
vname=list(file.NAME)
latmean=numpy.median(lat)
lonmean=numpy.median(lon)
html = """
Volcano name:<br>
<a href="https://www.google.com/search?q=%%22%s%%22" target="_blank">%s</a><br>
Height: %s m
"""
map = folium.Map(location=[latmean,lonmean], zoom_start=3, tiles="Mapbox Bright")
fg = folium.FeatureGroup(name="Volcanos")
for i,j,k,l in zip(vname,lat,lon,elev):
iframe = folium.IFrame(html=html % (i, i, l), width=200, height=100)
#fg.add_child(folium.Marker(location=[j,k], popup=folium.Popup(iframe), tooltip=i, icon=folium.Icon(color="red")))
fg.add_child(folium.CircleMarker(location=[j,k], radius=6, popup="Hi! I am "+i+" in "+str(j)+" and "+str(k)+"", tooltip="marker", fill_color="green", color="red", fill_opacity="1"))
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':'yellow' if x['properties']['POP2005']<10000000 else 'red'}))
map.add_child(fgp)
map.add_child(fg)
map.add_child(folium.LayerControl())
#map.save("Volcanoes.html")
map.save("Volcanoes_pophtml.html")