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

python使用pyecharts对给到的经纬度数据进行位置标注,下面是批量更新。给入数据,将地图生成。实验数据在下面附件。

python 复制代码
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)

结果:

资源内容如下:

相关推荐
开发者工具分享35 分钟前
如何应对敏捷转型中的团队阻力
开发语言
行云流水剑41 分钟前
【学习记录】如何使用 Python 提取 PDF 文件中的内容
python·学习·pdf
gregmankiw41 分钟前
C#调用Rust动态链接库DLL的案例
开发语言·rust·c#
roman_日积跬步-终至千里1 小时前
【Go语言基础【20】】Go的包与工程
开发语言·后端·golang
秦少游在淮海1 小时前
C++ - string 的使用 #auto #范围for #访问及遍历操作 #容量操作 #修改操作 #其他操作 #非成员函数
开发语言·c++·stl·string·范围for·auto·string 的使用
const5441 小时前
cpp自学 day2(—>运算符)
开发语言·c++
心扬1 小时前
python生成器
开发语言·python
mouseliu2 小时前
python之二:docker部署项目
前端·python
阿蒙Amon2 小时前
06. C#入门系列【自定义类型】:从青铜到王者的进阶之路
开发语言·c#
虾球xz2 小时前
CppCon 2015 学习:CLANG/C2 for Windows
开发语言·c++·windows·学习