-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfast_marker_cluster.py
33 lines (23 loc) · 1.07 KB
/
fast_marker_cluster.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 pandas as pd
import folium
from folium.plugins import FastMarkerCluster
import time
df = pd.read_csv('data/20190318-referentiel-arbre-namr.csv')
france_map = folium.Map(location=[46.603354, 1.888334], zoom_start=6)
start_time = time.time()
callback = """
function (row) {
var icon = L.AwesomeMarkers.icon({icon: 'glyphicon-tree-deciduous', markerColor: 'green'});
var marker = L.marker(new L.LatLng(row[0], row[1]));
marker.setIcon(icon);
var popupContent = '<b>' + row[2] + '</b>';
marker.bindPopup(popupContent);
return marker;
};"""
france_map.add_child(FastMarkerCluster(data=df[['y', 'x', 'genre_latin']].values.tolist(), callback=callback))
france_map.save('viz/urban_trees_map.html')
end_time = time.time()
execution_time_method = end_time - start_time
print("\nMethod 5: FastMarkerCluster")
print(f"Markers added: {len(df)}")
print(f"Execution time: {execution_time_method:.2f} seconds")