python使用pyecharts对给到的经纬度数据进行位置标注,下面是批量更新。给入数据,将地图生成。实验数据在下面附件。
from pyecharts import options as opts
from pyecharts.charts import Geo
import os
folder_path = 'F:\\GPS'
file_names = os.listdir(folder_path)
for file_name in file_names:
geo_chart = Geo()
open_path = folder_path+"\\"+file_name
geo_chart.add_schema(maptype="china")
with open(open_path, "r") as file:
lines = [line.strip() for line in file.readlines()]
points = [eval(line) for line in lines]
for i, point in enumerate(points):
geo_chart.add_coordinate(str(i), point[0], point[1])
geo_chart.set_global_opts(
title_opts=opts.TitleOpts(title="中国地图标记经纬度点"),
visualmap_opts=opts.VisualMapOpts(max_=10),
)
for i, point in enumerate(points):
geo_chart.add("", [(str(i), 1)])
geo_chart.set_series_opts(
effect_opts=opts.EffectOpts(symbol="circle", symbol_size=8, color="blue"),
label_opts=opts.LabelOpts(is_show=False),
)
save_path = "F:\\GPS\\"+file_name[:-4]+".html"
geo_chart.render(save_path)
file.close()
print(save_path)
结果:
资源内容如下: