python里turtle画随机点的分布图(python在地图上画路线)

技术Python如何根据站点列表绘制站坐标全球分布图本篇内容主要讲解“Python如何根据站点列表绘制站坐标全球分布图”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Pytho

本文主要讲解“Python如何根据站点列表绘制站点坐标的全局分布图”。感兴趣的朋友不妨看看。本文介绍的方法简单、快速、实用。让边肖带你学习“Python如何根据站点列表绘制站点坐标全球分布图”!

根据站点列表绘制站点坐标全球分布图。

输入:站点列表文件、SNX全球站点坐标文件

站点文件示例(可手动创建):

Python如何根据站点列表绘制站坐标全球分布图

输出:

Python如何根据站点列表绘制站坐标全球分布图

代码:

#coding=utf-8

#!/usr/bin/envpython

'''

program : plot _ global _ sitemap . py

功能:根据站点列表绘制站点坐标全球分布图。

作者:LZ_CUMT

版本:1.0

2021年12月10日:2021

'''

frommathimportpi,sqrt,atan,atan2,sin,cos

importmatplotlib.pyplotasplt

importmatplotlibasmpl

importcartopy.crsasccrs

import cartopy . featureas feature

from cartopy . mpl . tickerimportlongitudeformater,LatitudeFormatter

#xyz至llh(纬度和经度)

defxyz 2 LH(ecef,现场):

aell=6378137.0

下跌=1.0/298.257223563

deg=pi/180

u=ecef[0]

v=ecef[1]

w=ecef[2]

esq=2 *跌倒-跌倒*跌倒

lat=0

N=0

ifw==0:

lat=0

else:

lat 0=atan(w/(1-esq)* sqrt(u * u v * v))

j=0

delta=10^6

极限=0.000001/3600 *

而意大利限制:

n=aell/sqrt(1-esq * sin(lat 0)* sin(lat 0))

nbsp;         lat = atan((w / sqrt(u*u + v*v)) * (1 + (esq * N * sin(lat0) / w)))
            delta = abs(lat0 - lat)
            lat0 = lat
            j = j + 1
            if j > 10:
                break
    long = atan2(v, u)
    h = (sqrt(u*u+v*v)/cos(lat))-N
    llh = [site, long * 180 / pi, lat * 180 / pi, h]
    return llh

# 由站点文件获取站点列表存入sitelist
def getSite(listfile):
    sitelist = []
    f = open(listfile)
    ln = f.readline()
    while ln:
        sitelist.append(ln[0:4].upper())
        ln = f.readline()
    return sitelist

# 根据站点名在snx文件中搜索XYZ坐标转化为经纬度并输出
def getBLH_single(site,snxlines):
    xyz = [0, 0, 0]
    for ln in snxlines:
        if site in ln:
            if 'STAX   ' in ln:
                xyz[0] = float(ln[47:68])
            if 'STAY   ' in ln:
                xyz[1] = float(ln[47:68])
            if 'STAZ   ' in ln:
                xyz[2] = float(ln[47:68])
    blh = xyz2llh(xyz, site)
    if len(blh) != 4:
        print('[INFO] Sitecrd for', site, 'is not found in the snxfile')
    return blh

def getBLH(listfile, snxfile):
    siteBLH = []
    sitelist = getSite(listfile)
    f = open(snxfile)
    lns = f.readlines()
    for site in sitelist:
        siteBLH.append(getBLH_single(site, lns))
    return siteBLH

def plotsite(siteBLH):
    # mpl.rcParams['font.sans-serif'] = ['Helvetical']
    mpl.rcParams['axes.unicode_minus'] = False
    mpl.rc('xtick', labelsize=9)
    mpl.rc('ytick', labelsize=9)
    mpl.rcParams['xtick.direction'] = 'in'
    mpl.rcParams['ytick.direction'] = 'in'

    fig = plt.figure(figsize=(14, 7))
    ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=150))
    ax.set_extent([-180, 180, -90, 90], crs=ccrs.PlateCarree())
    ax.set_xticks([0, 60, 120, 180, 240, 300, 360], crs=ccrs.PlateCarree())
    ax.set_yticks([-90, -60, -30, 0, 30, 60, 90], crs=ccrs.PlateCarree())
    ax.add_feature(cfeature.LAND)
    ax.add_feature(cfeature.OCEAN)
    ax.add_feature(cfeature.COASTLINE, linewidth=0.1)

    for site in siteBLH:
        ax.plot(site[1], site[2], 'o', color='r', mec='k', mew=0.5, transform=ccrs.Geodetic(), ms=13.0)
        plt.text(site[1] + 1.5, site[2] + 1.5, site[0], transform=ccrs.Geodetic(),fontsize='x-large')  # 添加站名标注
    plt.xticks(fontsize='x-large')
    plt.yticks(fontsize='x-large')
    lon_formatter = LongitudeFormatter(zero_direction_label=True)
    lat_formatter = LatitudeFormatter()
    ax.xaxis.set_major_formatter(lon_formatter)
    ax.yaxis.set_major_formatter(lat_formatter)

    fig.savefig('global_sitemap.png', bbox_inches='tight', dpi=400)
    plt.show()

if __name__ == '__main__':
    listfile = r'site.info'               # 输入要画的站点列表文件
    snxfile = r'igs21P2177.snx'              # 输入IGS站坐标文件
    siteBLH = getBLH(listfile, snxfile)   # 获取所有站点的经纬度
    plotsite(siteBLH)           # 画图
    print('[INFO] Plot complete!')        # 完成

到此,相信大家对“Python如何根据站点列表绘制站坐标全球分布图”有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/149066.html

(0)

相关推荐

  • OpenEuler基础实验

    技术OpenEuler基础实验 OpenEuler基础实验OpenEuler基础实验
    20191331 lyx
    基于 鲲鹏--OpenEuelr 20.03 64bit--ARM (华为云服务器)
    实验

    礼包 2021年11月1日
  • spring事件机制实例(spring事件机制详解)

    技术Spring的事件机制知识点有哪些这篇文章主要讲解了“Spring的事件机制知识点有哪些”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Spring的事件机制知识点有哪

    攻略 2021年12月20日
  • 关于nodejs4

    技术关于nodejs4 关于nodejs4创建数据结构:
    1.下载安装Mongodb并配置环境变量
    2.新建文件
    3.在新文件中安装包
    4.输入:npm install mongoose执行命令
    ---

    礼包 2021年11月30日
  • 如何用Python爬取小红书

    技术如何用Python爬取小红书如何用Python爬取小红书,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。小红书首先,我们打开之前大家配置好的charles

    攻略 2021年10月26日
  • 租用香港服务器从事游戏相关业务有什么好处

    技术租用香港服务器从事游戏相关业务有什么好处香港服务器提供了部署所需游戏的灵活性和能力。它可以多方面提升游戏体验,并通过丰富的资源为您的服务器提供更好的安全性,因为您是独享硬件配置的。这可能解释了为什么现代游戏玩家和主播

    礼包 2021年12月21日
  • LeetCode538 把二叉搜索树转为累加树

    技术LeetCode538 把二叉搜索树转为累加树 LeetCode538 把二叉搜索树转为累加树题目
    给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum T

    礼包 2021年12月13日