算法热图? [英] Algorithm for heat map?

查看:450
本文介绍了算法热图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

予有每个纬度和经度值的列表。我希望创建一个半透明的热图图像重叠在谷歌地图。我知道有服务器端闪存解决方案了,但我想用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.

这篇关于算法热图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆