-
Notifications
You must be signed in to change notification settings - Fork 525
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
Alpha blend coincident data points #32
base: gh-pages
Are you sure you want to change the base?
Conversation
The grid mechanism basically combines data points that are closer than `cellSize` into a single data point. It was doing this by adding together the altitudes. If the grid is intended to be a higher-performance approximation of sending all of the individual data points to simpleheat, then this isn't the correct way to combine altitudes. In simpleheat, two points drawn on top of each other with altitude of `max * 0.5` would not look like a single point of altitude `max`, but rather `max * 0.75`, because they are combined using alpha blending. (The blurred part of the circle will always look a bit different--I don't know how you can fix that with the grid approach.) By using alpha blending, we can get rid of the `v` parameter, which (correct me if I'm wrong) was an attempt to prevent clustered points from always adding up to max intensity. Alpha blending solves this problem more directly. Getting rid of the `v` parameter means that adding a single point of altitude = `max` will appear with the maximum intensity of color, which is what you get with simpleheat and what users would expect. It also means that two max altitude points on top of each other will look the same (at least in the center) as one max altitude point, which is again a more correct/expected result.
Thanks for the PR! This indeed looks like an approach that makes the results more correct. However the point of the If you compare this branch with the original by zooming back and forth between zoom levels, you'll see that the original just looks better — heatmaps change between zoom levels more predictably. Could you adjust the PR so that it keeps the original idea while preserving the zoom adjustments? |
@mourner Thanks for your consideration! Can you tell me what example you're referring to? I'm looking at the 10,000 demo and it looks about the same to me--they both get pretty crazily inconsistent, shape-wise, when zooming between different levels. Hard coding The |
Friendly nudge :) If you don't have time to think about this, that's OK. We're trying to integrate heatmap functionality into the Leaflet package for R. If we have to, we can just take the alpha blended change on our own private copy of Leaflet.heat (but I'd prefer to match your repo if possible). |
Hey, sorry, a lot of stuff on my plate — vacation, then more travelling... I'm going to get back to this next week. |
I completely understand, I have more outstanding PRs on my projects than I care to think about... |
Hi @mourner any news on this? |
The grid mechanism basically combines data points that are closer than
cellSize
into a single data point. It was doing this by adding together the altitudes. If the grid is intended to be a higher-performance approximation of sending all of the individual data points to simpleheat, then this isn't the correct way to combine altitudes. In simpleheat, two points drawn on top of each other with altitude ofmax * 0.5
would not look like a single point of altitudemax
, but rathermax * 0.75
, because they are combined using alpha blending. (The blurred part of the circle will always look a bit different--I don't know how you can fix that with the grid approach.)By using alpha blending, we can get rid of the
v
parameter, which (correct me if I'm wrong) was an attempt to prevent clustered points from always adding up to max intensity. Alpha blending solves this problem more directly.Getting rid of the
v
parameter means that adding a single point of altitude =max
will appear with the maximum intensity of color, which is what you get with simpleheat and what users would expect. It also means that two max altitude points on top of each other will look the same (at least in the center) as one max altitude point, which is again a more correct/expected result.