#!/usr/bin/env python # coding: utf-8 # In[1]: import os import pandas as pd df = pd.read_csv(os.path.join("data", "highlight_flight_trajectories.csv")) # Let us take a glance at the data. # Each row represents the trajectory of a flight, # and the last column contains the coordinates of the flight path in `GeoJSON` format. # In[2]: df # In[3]: import folium m = folium.Map(location=[40, 10], zoom_start=4, control_scale=True, prefer_canvas=True) def style_function(feature): return {"fillColor": "#ffaf00", "color": "blue", "weight": 1.5, "dashArray": "5, 5"} def highlight_function(feature): return {"fillColor": "#ffaf00", "color": "green", "weight": 3, "dashArray": "5, 5"} for index, row in df.iterrows(): c = folium.GeoJson( row["geojson"], name=("{}{}".format(row["dep"], row["dest"])), overlay=True, style_function=style_function, highlight_function=highlight_function, ) folium.Popup("{}\n{}".format(row["dep"], row["dest"])).add_to(c) c.add_to(m) folium.LayerControl().add_to(m) m