deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Color based on Max value(Weight)

Open UttamRahane opened this issue 6 years ago • 11 comments

Generally in Heatmap, If wight is 10 for a point then it would be equivalent to having 10 points of weight 1 in the same spot.so it do the summation of nearest point. Can I take max value from those points not summation. ex. suppose I have given color range from yellow to red. and there are 10 points each having weight less than 5. there is one more point which is not close to those 10 points. and that point has weight 8. so the point having value 10 should be red and other 10 points are on the same point should look yellow.

UttamRahane avatar Dec 12 '19 11:12 UttamRahane

@UttamRahane , we can do this post distribution of weight. To generate heatmap, the weight of each point is distributed to all the neighboring pixels within a given radius using, a gaussian KDE (kernel density estimation). Points closer to it get higher weight , while points further away get much smaller weight. After above step, the weights that a point gets (from all other points) is aggregated to generate the final color. At this point, aggregation is done using SUM . But we can customize this to be a max value (we can support, min and mean too), but right now there is no public API. Does this serve your use case? For experimenting you can make flollowing change to this line link change blendEquation: GL.FUNC_ADD to blendEquation: GL.MAX

1chandu avatar Dec 12 '19 22:12 1chandu

Closing due to in activity, please re-open for any un-resolved questions.

1chandu avatar Jan 14 '20 23:01 1chandu

Hello @1chandu,

I am interested in the solution you propose - we use heatmaps for visualising current sensor measurement values in relation to the sensors min, max and on a color scale. So the sensors do not infer each other based on geolocation, but show raw values - if it would be possible to add a public way to change these settings, we would be grateful!

CaptainMack avatar May 01 '20 17:05 CaptainMack

@CaptainMack Hey! Have you found a solution?

Yankovsky avatar Oct 14 '20 16:10 Yankovsky

@CaptainMack @Yankovsky Thanks for your input. For timely response from a team member, do not reply to closed issues in the future. We do not monitor them.

Pessimistress avatar Oct 14 '20 16:10 Pessimistress

After above step, the weights that a point gets (from all other points) is aggregated to generate the final color. At this point, aggregation is done using SUM . But we can customize this to be a max value (we can support, min and mean too), but right now there is no public API. Does this serve your use case? For experimenting you can make flollowing change to this line link change blendEquation: GL.FUNC_ADD to blendEquation: GL.MAX

I tried to change blendEquation to GL.MAX as @1chandu suggested, but points stopped clustering: And changing to GL.MIN made all points disappear. Also there's no GL.MEAN or similar constant to use.

nekitk avatar Oct 15 '20 07:10 nekitk

@nekitk You can try 8.4.0-alpha.1 with the new aggregation prop:

new HeatmapLayer({
  ...
  aggregation: 'MEAN' // 'SUM' or 'MEAN'
})

Pessimistress avatar Oct 22 '20 17:10 Pessimistress

@Pessimistress thanks! just what we needed

nekitk avatar Oct 23 '20 07:10 nekitk

@Pessimistress one clarification though. I have an array of points with different weights. It may be that all of the points values are below desired maximum value. How can I set a minimum and maximum values for weight?

For example, I want to set weights range to [0, 10]. So even if a maximum weight between points is 5 it will be half of the maximum color. I tried to set colorDomain: [0, 10], but all my points were colored as maximum color regardless of their weight: image

I think I can overcome this by modifying colorRange dynamically, but I wonder if there'e a better way.

nekitk avatar Oct 23 '20 08:10 nekitk

I'm not sure I understand what you're trying to achieve. Can you create a codepen?

Pessimistress avatar Oct 28 '20 13:10 Pessimistress

ok, I'll open another issue

nekitk avatar Oct 28 '20 14:10 nekitk