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

Alpha blend coincident data points #32

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

jcheng5
Copy link

@jcheng5 jcheng5 commented Aug 28, 2015

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.

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.
@jcheng5
Copy link
Author

jcheng5 commented Aug 28, 2015

cc @timelyportfolio

@mourner
Copy link
Member

mourner commented Aug 28, 2015

Thanks for the PR! This indeed looks like an approach that makes the results more correct. However the point of the v parameter was to make intensity scale depending on how close it is to max zoom level, so that the heatmap makes more sense on lower zoom levels.

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?

@jcheng5
Copy link
Author

jcheng5 commented Aug 31, 2015

@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 cellSize = 1 seems to fix that quite effectively and on my machine is still quite fast, but then, even with clustering removed altogether, it's still pretty fast.

The v parameter means that a single point at full intensity won't look full intensity at any but the max zoom level. Shouldn't that be an optional feature at best? If your desire is to make the heatmaps change more predictably between zoom levels, perhaps scaling the radius (not necessarily 1:1 with the zoom) would make more sense?

@jcheng5
Copy link
Author

jcheng5 commented Sep 4, 2015

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).

@mourner
Copy link
Member

mourner commented Sep 18, 2015

Hey, sorry, a lot of stuff on my plate — vacation, then more travelling... I'm going to get back to this next week.

@jcheng5
Copy link
Author

jcheng5 commented Sep 18, 2015

I completely understand, I have more outstanding PRs on my projects than I care to think about...

@smartinsightsfromdata
Copy link

Hi @mourner any news on this?
(and thanks for the great work on heatmap!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants