question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

heat map plugin creating incorrect output

See original GitHub issue

The heat map plugin is not generating correct output, to test I have added 6 points with a weight and color gradient. The expected output should have these points at different colors

Any ideas what may be going wrong? I suspect underlying js works on count and ignore weights

import folium
from folium import plugins

m = folium.Map(location=[43.46811941, -90.04569087], zoom_start=5)
data = [[42.35810000, -71.06360000, 0.3],
        [42.82995815, -74.78991444, 0.4],
        [43.17929819, -78.56603306, 0.5],
        [43.40320216, -82.37774519, 0.6],
        [43.49975489, -86.20965845, 0.7],
        [43.46811941, -90.04569087, 0.8],]
# Uncommenting following does not work either
# append 0.0 and 10 to check if color scaling works correctly
# data.append([0,0,0.0])
# data.append([0,0,1.0])
# define color map

colormap = {0.0: 'pink', 0.3: 'blue', 0.5: 'green',  0.7: 'yellow', 1.0: 'red'}
m.add_children(plugins.HeatMap(data, min_opacity=1, max_val=1.0, gradient=colormap))
m.save('123.html')` 

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
achourasiacommented, Sep 3, 2016

We should add another template for heatmap.js which does the right thing and has a plugin for leaflet. Note the current library and the one I mention have similar names heat_map.js (creates incorrect output) vs heatmap.js (creates correct output)

Here are the links Heatmap.js: https://github.com/pa7/heatmap.js Leaflet plugin: https://github.com/pa7/heatmap.js/tree/master/plugins

1reaction
Clemmarchalcommented, Aug 13, 2020

The heat map plugin is not generating correct output, to test I have added 6 points with a weight and color gradient. The expected output should have these points at different colors

Any ideas what may be going wrong? I suspect underlying js works on count and ignore weights

import folium
from folium import plugins

m = folium.Map(location=[43.46811941, -90.04569087], zoom_start=5)
data = [[42.35810000, -71.06360000, 0.3],
        [42.82995815, -74.78991444, 0.4],
        [43.17929819, -78.56603306, 0.5],
        [43.40320216, -82.37774519, 0.6],
        [43.49975489, -86.20965845, 0.7],
        [43.46811941, -90.04569087, 0.8],]
# Uncommenting following does not work either
# append 0.0 and 10 to check if color scaling works correctly
# data.append([0,0,0.0])
# data.append([0,0,1.0])
# define color map

colormap = {0.0: 'pink', 0.3: 'blue', 0.5: 'green',  0.7: 'yellow', 1.0: 'red'}
m.add_children(plugins.HeatMap(data, min_opacity=1, max_val=1.0, gradient=colormap))
m.save('123.html')` 

I know this issue is old but this may be usefull for other people :

Your min_opacity is at 1 so there is no possible gradiant. Your minimum values will be displayed with the same opacity as your maximum value. Try this code instead :

import folium
from folium import plugins

m = folium.Map(location=[43.46811941, -90.04569087], zoom_start=5)
data_test = [[42.35810000, -71.06360000, 0.1],
       [42.82995815, -74.78991444, 0.2],
       [43.17929819, -78.56603306, 0.4],
       [43.40320216, -82.37774519, 0.6],
       [43.49975489, -86.20965845, 0.8],
       [43.46811941, -90.04569087,   1],]
# Uncommenting following does not work either
# append 0.0 and 10 to check if color scaling works correctly
# data.append([0,0,0.0])
# data.append([0,0,1.0])
# define color map

colormap = {0.0: 'pink', 0.3: 'blue', 0.5: 'green',  0.7: 'yellow', 1: 'red'}
#gradient=colormap,

m.add_child(plugins.HeatMap(data_test , min_opacity = 0, max_val = 0.00025, gradient=colormap, blur=1))

The base gradiant seems to have fixed values that go between 0 and 4000. So 0 is pink and 4000 is red in your gradiant. In order to display the values between 0 and 1, you have to put max_val at 0.00025.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Metadata layers are displayed incorrectly on results produced ...
Metadata layers are displayed incorrectly on results produced by the tool Create Heat Map for RNA-Seq - QIAGEN Digital Insights.
Read more >
Problem with Heatmap plotting by folium.plugins
I need the data to be an array that combines latitude, longitude, and the three values I want to make into a heat...
Read more >
How to use Heatmap plugin and its output?
Run the heat map plugin according to the instructions. Modifying the radius param should give you results consistent with the scale in the ......
Read more >
Aurora Heatmap – WordPress plugin
A simple WordPress heatmap that can be completed with just a plugin. ... The name “Aurora Heatmap” visualizes user behavior with a beautiful...
Read more >
Creating Heatmaps (QGIS3) - QGIS Tutorials and Tips
Notice that OUTPUT layer in the Layers panel has a legend but the 2019-02-surrey-street layer does not. A common problem with using a...
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found