python - 用 folium 绘制标记是否有限制?

标签 python pandas plot data-science folium

我正在策划美国空军在朝鲜 war 期间对朝鲜执行的任务。

以下是2800个地 block 的 map 。

enter image description here

我总共有大约 7500 个图,但是每当我尝试在 2800 以上绘制时,都会渲染一个空白 map 。我正在使用 PC 笔记本电脑进行渲染。如果我使用桌面,它会呈现吗?或者这是对叶的限制?

我不推测这是数据的问题。如果有人想探索它,我将分享坐标数据:link到公共(public) excel 表。

最佳答案

正如@Bob Haffner 建议的那样,您可以使用 Folium 库中的 FastMarkerCluster。
这是我的代码,在我的文件中有 ~500K 点。

import pandas as pd
import json
from folium.plugins import FastMarkerCluster

rome_lat, rome_lng = 41.9028, 12.4964
with open("file_name.json", 'r') as f:
  # create a new DataFrame
  samples = pd.DataFrame(json.loads(f.read()))        
# init the folium map object
my_map = folium.Map(location=[rome_lat, rome_lng], zoom_start=5)
# add all the point from the file to the map object using FastMarkerCluster
my_map.add_child(FastMarkerCluster(samples[['latitude', 'longitude']].values.tolist()))
# save the map 
my_map.save("save_file.html")
此代码需要大约 10 毫秒来渲染 map 。
有关更多详细信息示例,请点击此链接:
FastMarkerCluster example
希望这会有所帮助。

关于python - 用 folium 绘制标记是否有限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49984575/

相关文章:

python - 以编程方式获取 Skype for Business 状态

python - pandas groupby.agg() 采用分类变量的模式,其中 NaN 是组的唯一变量

matlab - 在 MATLAB 中使用 plot3 绘制圆锥体

python - 将一列拆分为多列,计数频率: 'int' object is not iterable

python - 从 seaborn 中保存情节

image - 在 MATLAB 中使用 imshow 方法显示图像标题

python - pandas 人类索引排序

python - sklearn 中 score 和 accuracy_score 的区别

python - 使用python将文件夹添加到zip文件

python - 如何格式化 Twitter(和其他)时间戳?