You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I spend quite some time tracking down this bug. I think it should be fixed or the limitation should be clearly stated in the docs. This is a major time waster and makes a bad impression on this otherwise great package.
This is a major bug coming for the upstream Leaflet.heat project.
Hi @ibayer , sorry to hear this bug caused you some issues. I opened a PR which applies a patch from the leaflet.heat repo. Can you perhaps help by testing the PR, see if it solves the issue for you?
Alternatively, if we don't get a fix working, we should indeed update the documentation.
Thanks for looking into this! Sorry, project has moved on and I don't have any code handy to
reproduce / test your fix. When I get the opportunity I'll for sure give folium another shot in the future but that might take a while.
We have a fix pending that I have to finish up. When that's merged you can install folium from the master branch. A new release (v0.12.0) is not yet scheduled, but will follow reasonably soon.
You could help out by testing the fix and reporting if it worked for you: #1282
Thanks @Conengmo for looking into this!
I am using Version: 0.11.0+19.g46f820e.
Somehow it uses weights, but not correctly. In the attached figure you can see that 4 circles are equally weighted and one has higher intensity. However I would expect something else when choosing the weights 1,2,3,4 and 10.
A similar behaviour can be found for example for weights 0.1, 0.2, 0.3, 0.4, 0.8. The first 4 are equally and only the last has a higher intensity.
Weights in heatmaps can work a bit non-intuitive. I suspect that one value of 10 is so high that the other values are all small relatively. Please try a range where the values are closer together and see how that looks. For example some values between 1 and 2.
Thanks for the fast response.
When I use weights of {1, 2, 3, 4, 5} it seems to work.
However, when I use {0.1, 0.2, 0.3, 0.4, 0.5} I dont see any effect at all.
Would be nice to know in which range the weights needs to be to see weighting having effect. It might be a good idea to normalise the given weights to the range where it works.
I'm hesitant to do normalization, because I don't think we can determine an optimal range automatically. That depends not only on the weights, but also on the locations of the points, the zoom level and the radius settings.
Hi, I am new to this subject but I've tried playing with the min_opacity and the max_value and this works fine :
m=folium.Map((0.5, 0.5), zoom_start=8, tiles=None)
HeatMap(
# make five dots with different weights: 1, 2, 3, 4 and 5data=[(0 , 0, 0.1),
(0.5, 0, 0.2),
(1.0, 0, 0.3),
(1.5, 0, 0.4),
(2.0, 0, 0.5)] , radius=25, blur=10, min_opacity=0, max_val=0.0005).add_to(m)
m
It seems that max_value works like a normalisation. So if you want to display value between 1 and 5, you have to put the max_value at 0.005 and so on...
Note that you're using v0.11.0 and we were talking about the master branch, which contains a fix for heatmaps and changes its behavior slightly. With the fix, max_val is deprecated.
Hello,
As of today (folium 0.12.1), the heatmap is still showing some unexpected behaviors. Below is an example.
Barcelona should be shown "hotter" than Augsburg but they appear to be of the same "heat".
NL looks "hotter" than Augsburg and Barcelona even though its weight is only 5 (2+3). My guess is that the number of locations is much more important than their weight.
Edit for point 1): I believe the disparity between the different volumes is too high. Taking the log2 of the column "Volume" seems to give more expected results. Point 2) is still relevant.
Following my last comment, it seems that there are also different behaviors depending on the zoom of the map (see screenshot below - look at Polska and Katowice).
Activity
Conengmo commentedon Apr 7, 2020
Hi @ibayer , sorry to hear this bug caused you some issues. I opened a PR which applies a patch from the leaflet.heat repo. Can you perhaps help by testing the PR, see if it solves the issue for you?
Alternatively, if we don't get a fix working, we should indeed update the documentation.
ibayer commentedon Apr 9, 2020
@ibayer
Thanks for looking into this! Sorry, project has moved on and I don't have any code handy to
reproduce / test your fix. When I get the opportunity I'll for sure give folium another shot in the future but that might take a while.
Conengmo commentedon Apr 9, 2020
No problem, then thanks for the bug report :)
MiguelRodriguezAnticona commentedon May 14, 2020
Hi i Have the same problem so far, what is the solution?
Conengmo commentedon May 14, 2020
We have a fix pending, I reckon it will be in the next release. In the meantime you could test it out by manually applying it: https://github.com/python-visualization/folium/pull/1282/files
MiguelRodriguezAnticona commentedon May 14, 2020
Conengmo this work in R?
Conengmo commentedon May 14, 2020
No this is a Python library
fcs30 commentedon Jun 4, 2020
Hello! I have the same problem - is the best solution still manually applying it? When is the next released planned for?
Conengmo commentedon Jun 5, 2020
We have a fix pending that I have to finish up. When that's merged you can install folium from the master branch. A new release (v0.12.0) is not yet scheduled, but will follow reasonably soon.
You could help out by testing the fix and reporting if it worked for you: #1282
rbiele02 commentedon Aug 5, 2020
Still not working correctly. I would expect another output.
Please do try the following code to see the problem:
m = folium.Map((0.5, 0.5), zoom_start=8, tiles=None)HeatMap(# make five dots with different weights: 1, 2, 3, 4 and 10data=[(0, 0, 1),(0.5, 0, 2),(1.0, 0, 3),(1.5, 0, 4),(2.0, 0, 10)] , radius=15).add_to(m)mJust on sphere is bigger, there is no continuous gradient between 1 and 10.
Conengmo commentedon Aug 12, 2020
@rbiele02 which folium version are you using?
rbiele02 commentedon Aug 12, 2020
Thanks @Conengmo for looking into this!
I am using Version: 0.11.0+19.g46f820e.
Somehow it uses weights, but not correctly. In the attached figure you can see that 4 circles are equally weighted and one has higher intensity. However I would expect something else when choosing the weights 1,2,3,4 and 10.
A similar behaviour can be found for example for weights 0.1, 0.2, 0.3, 0.4, 0.8. The first 4 are equally and only the last has a higher intensity.
Conengmo commentedon Aug 12, 2020
Weights in heatmaps can work a bit non-intuitive. I suspect that one value of 10 is so high that the other values are all small relatively. Please try a range where the values are closer together and see how that looks. For example some values between 1 and 2.
We have a test that verifies the behavior when using weights, so I'm fairly sure it's not broken. In it we create four points with weights 1, 1, 1.5 and 2: https://github.com/python-visualization/folium/pull/1282/files#diff-b6e9c94435e2e8e2a966d436a06a52b6R16 The result looks like this: https://github.com/Conengmo/folium/blob/cce48dc1fd46e23fefd84d6011c6a132f08ad006/tests/selenium/test_heat_map_selenium_screenshot.png
rbiele02 commentedon Aug 12, 2020
Thanks for the fast response.

When I use weights of {1, 2, 3, 4, 5} it seems to work.
However, when I use {0.1, 0.2, 0.3, 0.4, 0.5} I dont see any effect at all.

Would be nice to know in which range the weights needs to be to see weighting having effect. It might be a good idea to normalise the given weights to the range where it works.
Conengmo commentedon Aug 12, 2020
Can you try {0.5, 1, 1.5} ? Maybe it assumes a minimum weight of 1...
Looking at the plugin documenation it seems to suggest values below 1 are valid: https://github.com/Leaflet/Leaflet.heat
I'm hesitant to do normalization, because I don't think we can determine an optimal range automatically. That depends not only on the weights, but also on the locations of the points, the zoom level and the radius settings.
rbiele02 commentedon Aug 12, 2020
{0.5, 1, 1.5} works very well!
{0, 0.5, 1.0} not really. Maybe it needs to be centred around 1? Also {0.8,1.0,1.2} looks reasonable.
I can shift my distribution to have a mean of 1. This might work.
Thanks a lot!
Conengmo commentedon Aug 12, 2020
I think it's safe to say it assumes a default weight of 1 then.
Clemmarchal commentedon Aug 13, 2020
Hi, I am new to this subject but I've tried playing with the min_opacity and the max_value and this works fine :
It seems that max_value works like a normalisation. So if you want to display value between 1 and 5, you have to put the max_value at 0.005 and so on...
I'm using follium 0.11.0
Conengmo commentedon Aug 13, 2020
Note that you're using v0.11.0 and we were talking about the master branch, which contains a fix for heatmaps and changes its behavior slightly. With the fix,
max_valis deprecated.Clemmarchal commentedon Aug 13, 2020
Thanks @Conengmo I didn't get it. Your patch automatically set the
max_valdepending on the intensity of the data ?How can I use it ?
Conengmo commentedon Aug 13, 2020
You can install folium with pip from the master branch like this:
pip install git+https://github.com/python-visualization/folium.gitBriceChivu commentedon Aug 19, 2021
Hello,

As of today (folium 0.12.1), the heatmap is still showing some unexpected behaviors. Below is an example.
Edit for point 1): I believe the disparity between the different volumes is too high. Taking the log2 of the column "Volume" seems to give more expected results. Point 2) is still relevant.
BriceChivu commentedon Aug 19, 2021
Following my last comment, it seems that there are also different behaviors depending on the zoom of the map (see screenshot below - look at Polska and Katowice).



