2

I have been creating Heat Maps with a Time dimension using both test data and my own datasets using the Folium libraries in Python. I am using Python 3.5 to do this, and the results have been good.

I have been away and one returning I have noticed that these scripts no longer produce a result that is viewable.

The scripts run without error, and the outputs open with the correct basemaps, however, the heatmap and the time sliders are no longer visible.

At first I thought it was the data I was using, but I have a test script taken from Git that I have been using to test some formatting and displays, but this no longer works.

https://github.com/python-visualization/folium/blob/master/tests/plugins/test_heat_map_withtime.py

import folium
import folium.plugins as plugins
import numpy as np
import webbrowser

from datetime import datetime, timedelta

np.random.seed(3141592)
initial_data = (
    np.random.normal(size=(100, 2)) * np.array([[1, 1]]) +
    np.array([[48, 5]])
)

move_data = np.random.normal(size=(100, 2)) * 0.01

data = [(initial_data + move_data * i).tolist() for i in range(100)]


weight = 1  # default value
for time_entry in data:
    for row in time_entry:
        row.append(weight)

print (data)

time_index = [
    (datetime.now() + k * timedelta(1)).strftime('%Y-%m-%d') for
    k in range(len(data))
]

print (len(time_index))

m = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)

hm = plugins.HeatMapWithTime(
    data,
    index=time_index,
    auto_play=True,
    max_opacity=0.3
)

hm.add_to(m)
m.save (r'c:\temp\Time.html')
webbrowser.open(r'c:\temp\Time.html')

Has something changed with the Folium libraries / anything? I thought maybe it was a firewall issue at work, but even going offline / using a connection outside of work produces the same result:

A Basemap, with no data to display.

  • Hey, I've upgraded to folium 0.10.1 and still having the problem where I see only base map. Any suggestions? I've ran your code and it still doesn't seem to work. – Ambleu Jan 28 at 1:42
  • I just checked and I am still on 0.10.1 and the above codes works. What version of Python you running? – Keagan Allan Jan 28 at 4:16
  • 1
    It worked after replacing ttps://rawcdn.githack.com/socib/Leaflet.TimeDimension/master/dist/leaflet.timedimension.min.js with https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.0/dist/leaflet.timedimension.min.js Inside heat_map_withtime.py file – Ambleu Jan 28 at 4:54
1

There has been an update in December 2019 upgrade folium and it should return, mine have today on doing pip install folium --upgrade

| improve this answer | |
  • Upgraded and my heatmaps are working again... – Keagan Allan Dec 4 '19 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.