-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathf_4.py
More file actions
60 lines (40 loc) · 1.27 KB
/
f_4.py
File metadata and controls
60 lines (40 loc) · 1.27 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 18 09:16:23 2020
@author: metivier
folium maps
using Cluster Markers to plot the place where students where
the year before registering at IPGP
"""
import folium
from folium.plugins import MarkerCluster
from sqlalchemy import create_engine
import pandas as pd
import numpy as np
#create the map
macarte = folium.Map(location=[46.5,2.5], zoom_start=6)
engine = create_engine("mysql://login:password@localhost/Parcours")
sql = "select cp, prenom from IdentiteTbl i inner join ParcoursTbl p on i.idetudiant=p.idetudiant where annee=anneeufr-1 and pays='France'"
stud = pd.read_sql(sql,engine)
f=open('../../Data/folium/data/laposte_hexasmal_1.csv')
line=f.readline()
lines=f.readlines()
codep=[]
lat=[]
lon=[]
for l in lines:
d=l.split(',')
codep.append(d[2])
lat.append(d[5])
lon.append(d[6].strip('\n'))
data={'cp':codep, 'lat':lat, 'lon':lon}
cp = pd.DataFrame(data,columns=['cp','lat','lon'])
ccp= cp.drop_duplicates('cp')
merged=stud.set_index('cp').join(ccp.set_index('cp'))
merged=merged.dropna()
mc = MarkerCluster()
for index, row in merged.iterrows():
mc.add_child(folium.Marker(location=[row['lat'],row['lon']],popup=row['prenom']))
macarte.add_child(mc)
macarte.save('f_4.html')