算法热图?算法、热图

由网友(花顔ミ诱人醉╮)分享简介:予有每个纬度和经度值的列表。我希望创建一个半透明的热图图像重叠在谷歌地图。我知道有服务器端闪存解决方案了,但我想用canvas标签中的JavaScript构建此。I have a list of values each with latitude and longitude. I'm looking to crea...

予有每个纬度和经度值的列表。我希望创建一个半透明的热图图像重叠在谷歌地图。我知道有服务器端闪存解决方案了,但我想用canvas标签中的JavaScript构建此。

I have a list of values each with latitude and longitude. I'm looking to create a translucent heatmap image to overlay on Google Maps. I know there are server side and flash based solutions already, but I want to build this in javascript using the canvas tag.

不过,我似乎无法找到一个简要说明用于打开坐标值转换为热图的算法。任何人都可以提供或者链接到一个?

However, I can't seem to find a concise description of the algorithm used to turn coordinates and values into a heatmap. Can anyone provide or link to one?

感谢。

推荐答案

基本的想法是创建一个网格,每一个项目的纬度,经度坐标到电网。我会用整数的二维数组。

The basic idea would be to create a grid and project every lat,lng coord to that grid. I would use a 2D array of ints.

在psuedo- code将是:

The psuedo-code would be:

for each coord
  cell = coord projected to grid
  increment cell value
end

for 0 to # of passes
  for each row
   for each col
     if grid[row,col] > 0 then
       grid[row,col] += 1
       increment_adjacent_cells(row, col)
     end
   end
  end
end

所以,这个想法是,int值越高,越热的细胞。 increment_adjacent_cells应该增加在所有8个相邻单元格的值。

So, the idea is that the higher the int value, the hotter that cell is. increment_adjacent_cells should increment the values in all 8 adjacent cells.

阅读全文

相关推荐

最新文章