如何在地图上绘制具有不同颜色网格的热图?

huangapple go评论69阅读模式
英文:

How to draw a heatmap with grids of different colors in a map?

问题

[Fig.1]:https://i.stack.imgur.com/YUbeF.png

感谢您事先的时间和专业知识。

最好的问候

英文:

Recently I have been reading a paper called Modeling Taxi Drivers’ Behaviour for the Next Destination Prediction. There is a figure(Fig.1) that I wonder how to draw. Based on what I know, it may be drawn by Python. Then what library of Python should I use to draw such a heatmap?

Thanks a lot in advance for your time and your expertise.

Best Regards

答案1

得分: 0

  1. 构建网格:
    地图上的网格是纬度和经度的X大小的正方形。简而言之,这些是纬度和经度网格。我使用了一个名为leaflet.js的交互式地图库来在世界地图上叠加纬度和经度网格。这是我遵循的leaflet教程链接: https://leafletjs.com/examples/choropleth/
    请记住,您可以按照教程中讨论的使用GeoJSON构建网格的方式来创建自己的版本,并叠加到世界地图上。至少在我构建时,还没有公开可用的纬度/经度正方形网格版本。

  2. 显示颜色(热力图):
    一旦您使用GeoJSON构建了网格,leaflet可以将整个GeoJSON作为它本来的形式叠加到您选择的任何地图上。这意味着您可以将每个网格的数字(也称为数据)放入GeoJSON中。这一部分也在同一教程中展示。
    对于我的项目,我习惯于在Python中创建一个完整的GeoJSON格式文件,其中包含规范化的数据,然后在leaflet.js中可视化它。下面是我使用这些工具构建的示例。
    如何在地图上绘制具有不同颜色网格的热图?

英文:

I have built something very similar for myself in the past. However, as you are just wondering how this would be drawn and not exactly asking how to do it with Python, I will share how I did it.

1. Building Grid:

The grids on the map are squares of X-size latitude and longitude. In short, those are latitude and longitude grids. I used an interactive map library named leaflet.js to build the world map with an overlay of latitude and longitude grids. This is the tutorial I followed from the leaflet: https://leafletjs.com/examples/choropleth/

Remember, you have to and can build your version of the grid to overlay on a world map using GeoJSON as discussed in the tutorial. At least, when I was building, there wasn't a publicly available version of the lat/long square grid.

2. Showing Colors (Heatmap):

Once you build the grid with GeoJSON, the leaflet can take the whole GeoJSON as it is and overlay it on any map of your choice. That means you can put the numbers(aka data) for each grid in the GeoJSON. This part is also shown in the same tutorial.

For my project, I used to create a complete GeoJSON formatted file with normalized data in Python and then visualize it in leaflet.js. Below is an example of what I have built using these tools.

如何在地图上绘制具有不同颜色网格的热图?

huangapple
  • 本文由 发表于 2023年2月18日 21:13:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75493573.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定