Skip to content
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

Does the intensity/altitude value work with individual points? #43

Open
eddielu opened this issue Dec 2, 2015 · 13 comments
Open

Does the intensity/altitude value work with individual points? #43

eddielu opened this issue Dec 2, 2015 · 13 comments
Assignees
Labels

Comments

@eddielu
Copy link

eddielu commented Dec 2, 2015

It seems that the only way to have sections show up as higher color intensities is to have several points clustered close together.

In other words, when given individual points (that are far apart from another) with different altitude values, the heatmap will show the same color of intensity for all points. Is this expected behavior?

@jameslaneconkling
Copy link

@eddielu No, the plugin should work with an array of individual points where the altitude values represent the intensity at that point (as explained in the docs).

I am having the same issue with the most recent version of leaflet.heat, which seems buggy. The following test code...

var heatData = [
    [
      -85.4667,
      -142.4,
      1
    ],
    [
      -38.0364,
      141.9025,
      278
    ],
    [
      -39.05835,
      174.82185,
      1596
    ],
    ...
];

var heatmap = L.heatLayer(heatData, {
  minOpacity: 0.1,
  max: _.maxBy(heatData, function(latLngDensity) { return latLngDensity[2]; })[2],
  radius: 70,
  blur: 30,
  gradient: {
    0.4:  '#f23e45',
    0.50: 'lime',
    0.70: 'yellow',
    0.95: '#FF8300',
    1.0:  'red'
  }
}).addTo(map);

produces the following:

screenshot 2016-01-17 18 46 48

However, when I run the exact same code with an older version of leaflet.heat (which I pulled out of a legacy project I'm taking over--the version number wasn't recorded), it produces something that looks like what I expect:

screenshot 2016-01-17 18 45 49

If in the first example with the current version I manually set max to 15 (rather than the actual max altitude of ~61,000), it starts to look like what is produced in the second example.

Leads me to think there's something buggy with the most recent version. Will compare the two versions I'm working with to see if I can pinpoint the issue. If anyone has any suggestions, please post.

I'm running these tests in Chrome 47.0.2526.106 (64-bit).

@mourner
Copy link
Member

mourner commented Jan 18, 2016

@jameslaneconkling looks like a perfect case for using git bisect! I'll be happy to know what the issue is too.

@mourner mourner added the bug label Jan 18, 2016
@jmpatricior
Copy link

I'm having the same problem with the most recent version, can anyone tell me how to get an older version without that bug?
Thanks.

@entone
Copy link

entone commented Feb 29, 2016

same issue here

spacemansteve added a commit to spacemansteve/Leaflet.heat that referenced this issue Mar 31, 2016
…blem when intensity not present

based on some code very kindly provided by github user jameslaneconkling.
the code in L.heat that redraws the layers was multiplying intensities by a value related to the zoom level stored in
a variable named v.  v is typically a very small number, ranging from .008 to .00002.  The code works better if it
just uses the intensity value.  Since I only provide points with an intensity value set, I'm not sure what happens when
the intensity isn't set.
The code probably breaks.  This commit is not intended as a permanent fix.  Instead, it highlights where the problem is.
I hope someone that knows the code better considers re-organizing the render loop perhaps treating separating it into two
distinct pieces: one for when intensities are provided and one where they are not.
@Rikuoja
Copy link

Rikuoja commented Apr 21, 2016

+1, my problem is probably related to this one.

Namely, changing the background map (as I have several maps with different resolutions) will completely change the heatmap even when the data stays the same. This is probably due to point intensity being related to the zoom level, instead of staying the same?

spacemansteve added a commit to spacemansteve/Leaflet.heat that referenced this issue May 10, 2016
@jonl-percsolutions-com
Copy link

I have committed a pull request which resolves this issue:

#60

@cpunekar
Copy link

@jameslaneconkling If you have the older version of this library, can you please share?

@samhatchett
Copy link

I wonder if this is the culprit:
https://github.com/Leaflet/Leaflet.heat/blob/gh-pages/src/HeatLayer.js#L170

... instead of just accumulating the k value, seems like it should be doing a cumulative moving average: cell[2] = cell[2] + (k - cell[2]) / (n + 1) - similar to the way the x/y coordinates are spatially averaged with alt weighting. Would need to keep a running n++ that tracks the number of points being considered within a cell, or offer a specifiable behavior here; does the user want to sample the mean/median/max cell value? I could imagine wanting different things from the display.

I see that in L183 the cell[2] accumulated value gets Math.min'd with the heat map's "max" value - which will effectively saturate the display for any non-sparse point field. That is to say, cell[2] will quickly outgrow the "max" if more than one point is aggregated onto a cell.

This issue looks like it may be related to #65 also.

@klonuo
Copy link

klonuo commented Sep 15, 2016

This bug is 9 month old.
Which version works correct, as current is still incorrect?

@debjan
Copy link

debjan commented Sep 19, 2016

People, isn't this critical or I miss something? Couldn't you write about this limitation in readme, instead praising how tiny and fast it is, so that we don't hit the wall, then google and browse issues to find nothing?

For other poor souls, I found that this plugin behaves as one would expected from heatmap: https://www.patrick-wied.at/static/heatmapjs/plugin-leaflet-layer.html

Although if you read this issue you are already aware perhaps...

@mourner mourner self-assigned this Sep 19, 2016
@mourner
Copy link
Member

mourner commented Sep 19, 2016

Sorry, with so many open source repos to maintain, this went off my radar. I'm going to triage some issues in Leaflet.heat this week and hopefully fix or clear up the biggest hurdles.

Harvinator added a commit to Harvinator/Leaflet.heat that referenced this issue Nov 24, 2016
This patch works by automatically setting the max as it changes on each zoom level as points get combined/separated.

You no longer need to manually set options.max

When calculating the max value it considers all points (even if they are off the screen). This way you always get the same results at a particular zoom level.

Thanks to @spacemansteve for pointing me in the right direction
ca1f430
@Harvinator
Copy link

Hi guy's,

I've submitted a pull request which potentially resolves this issue #78

It removes the max option and instead works it out for itself at each zoom level after points have been consolidated.

svancise added a commit to svancise/Leaflet.heat that referenced this issue Apr 21, 2017
Leaflet#43 Patch to fix intensity/altitude issue (auto max)
ajhbh added a commit to ajhbh/Leaflet.heat that referenced this issue Jul 31, 2018
Leaflet#43 Patch to fix intensity/altitude issue (auto max)
@MiguelRodriguezAnticona

I have the same problem so far, what is the solution?

traoredev added a commit to traoredev/Leaflet.heat that referenced this issue Jan 28, 2021
…issue

Leaflet#43 Patch to fix intensity/altitude issue (auto max)
BenTalagan added a commit to BenTalagan/Leaflet.heat that referenced this issue Jun 9, 2021
Leaflet#43 Patch to fix intensity/altitude issue (auto max)
jgartor added a commit to dataxquare/Leaflet.heat that referenced this issue Nov 17, 2021
Leaflet#43 Patch to fix intensity/altitude issue (auto max)
GavMason added a commit to mitre/Leaflet.heat that referenced this issue Jun 28, 2022
Leaflet#43 Patch to fix intensity/altitude issue (auto max)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests