7

I am plotting an hourly update of the devices on different maps. To animate and analyze the update I'm displaying a new plot at each iteration by clearing out the output of the cell in jupyter.

map_ = [[] for i in range(max(dfByDeviceidHourly['hour'])+1)]
for hour in dfByDeviceidHourly['hour'].unique():
    df_map = dfByDeviceidHourly[dfByDeviceidHourly['hour'] == hour]
    map_[hour] = folium.Map(location=list(df_map[['geocoordinates_latitude','geocoordinates_longitude']].mean()), zoom_start=13)
    for i,mark in enumerate(df_map):
        folium.Marker(list(df_map[['geocoordinates_latitude','geocoordinates_longitude']].iloc[i]), popup='The Waterfront').add_to( map_[hour] )
    clear_output(wait = True)
    display(map_[hour])
    time.sleep(4)

enter image description here

Is there a way in which I can make a video or gif out of the above?

I found one method (here: https://github.com/python-visualization/folium/issues/35) which involves saving the images as html, converting them into png, creating a gif out of them and then rendering it on the notebook. Though I'm looking for a more robust alternative for it.

Abhijay Ghildyal
  • 4,044
  • 6
  • 33
  • 54

0 Answers0