开发者

Uniform Grid Subdivision of Points in C#

I have a set P of 2D points that I could like to cluster in a 2D uniformly spaced grid, where each cell is length X.

I want to do this because I am trying to create a heat map, and I have way to much information so I am hoping by clustering the points into a uniformly spaced grid I can just report the final count of each grid.

Thanks!

if It makes any difference I am getting my开发者_运维知识库 information via SQL (the points) that are within a certain radius of a specified point first prior to subdivision.


Are you looking for something like this?

var result = from p in points
              group p by new { X = p.X / length, Y = p.Y / length } into g
              select new
              {
                  g.Key.X,
                  g.Key.Y,
                  Count = g.Count()
              };

I don't know if there's a way to take advantage of the order of points.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜