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

更新
最近又发现了更好用的工具keplergl,基本不需要写代码,拿着数据拆箱即用。
欢迎访问我的这篇博客:酷炫Keplergl


实现功能:将轨迹数据可视化到地图上
适用范围:车辆、船舶 等含有GPS定位系统的均可
编程语言:python


效果展示:
在这里插入图片描述


数据说明:需要”经度“和”纬度“这两列的信息。【63627.csv】
在这里插入图片描述
:如果是西经、南纬,需要是负值哦~


代码实现

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rcParams

import cartopy.feature as cf
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter

rcParams['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

评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值