1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python Cartopy 船舶轨迹数据可视化 【GPS AIS VMS】

python Cartopy 船舶轨迹数据可视化 【GPS AIS VMS】

时间:2023-04-12 09:32:23

相关推荐

python Cartopy 船舶轨迹数据可视化 【GPS AIS VMS】

更新

最近又发现了更好用的工具keplergl,基本不需要写代码,拿着数据拆箱即用。

欢迎访问我的这篇博客:酷炫Keplergl

实现功能:将轨迹数据可视化到地图上

适用范围:车辆、船舶 等含有GPS定位系统的均可

编程语言:python

效果展示:

数据说明:需要”经度“和”纬度“这两列的信息。【63627.csv】

:如果是西经、南纬,需要是负值哦~

代码实现

import seaborn as snsimport pandas as pdimport matplotlib.pyplot as pltimport numpy as npfrom matplotlib import rcParamsimport cartopy.feature as cfimport cartopy.crs as ccrsfrom cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatterrcParams['font.family']=rcParams['font.sans-serif']='SimHei' #font.family局部字体,font.sans-serif全局字体df=pd.read_csv(r'C:\Users\admin\Desktop\63627.csv')fig1=plt.figure()lon1,lon2,lat1,lat2=119,128,23,35 #最小经度,最大经度,最小纬度,最大纬度#绘制底图ax=plt.axes(projection=ccrs.PlateCarree())ax.set_extent([lon1,lon2,lat1,lat2],crs=ccrs.PlateCarree()) #设置地图展示的范围ax.add_feature(cf.COASTLINE,lw=0.3)ax.add_feature(cf.LAND)ax.add_feature(cf.OCEAN)ax.add_feature(cf.RIVERS)#绘制船舶轨迹sns.scatterplot(data=df,x='longitude',y='latitude',s=1,color='orangered')#设置x、y轴的刻度ax.set_xticks(np.arange(lon1,lon2,2))ax.set_yticks(np.arange(lat1,lat2,2))lon_formatter=LongitudeFormatter(zero_direction_label=False)lat_formatter=LatitudeFormatter()ax.xaxis.set_major_formatter(lon_formatter)ax.yaxis.set_major_formatter(lat_formatter)#设置标题和坐标轴名称plt.title('轨迹可视化')plt.xlabel("经度")plt.ylabel('纬度')plt.show()

更多的功能可以参考官网:Cartopy

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。