python用pychart库,实现将经纬度信息在地图上显示

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)

结果:

python用pychart库,实现将经纬度信息在地图上显示_第1张图片

资源内容如下:
python用pychart库,实现将经纬度信息在地图上显示_第2张图片

你可能感兴趣的:(python,python自动化,python,信息可视化,开发语言)