-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HeatMap doesn't use weights #1271
Comments
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 |
No problem, then thanks for the bug report :) |
Hi i Have the same problem so far, what is the solution? |
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 |
Conengmo this work in R? |
No this is a Python library |
Hello! I have the same problem - is the best solution still manually applying it? When is the next released planned for? |
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 |
Still not working correctly. I would expect another output.
Just on sphere is bigger, there is no continuous gradient between 1 and 10. |
@rbiele02 which folium version are you using? |
Thanks @Conengmo for looking into this! |
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 |
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. |
{0.5, 1, 1.5} works very well! I can shift my distribution to have a mean of 1. This might work. |
I think it's safe to say it assumes a default weight of 1 then. |
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 5
data=[(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... I'm using follium 0.11.0 |
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, |
Thanks @Conengmo I didn't get it. Your patch automatically set the |
You can install folium with pip from the master branch like this: |
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.
Problem description
The
plugins.HeatMap
states that the points used to create the heat map canbe weighted.
However weights are simply ignored. This makes it useless for heatmaps that are based on a few points with different weights.
Expected Output
Weight should have impact. Or remove this option from the docs.
The text was updated successfully, but these errors were encountered: