Python:如何在地图上绘制飞行轨迹/例程

问题描述 投票:0回答:1

我正在尝试使用位置数据在地图上绘制飞行例程。

我得到了位置数据,其中还包含其他信息。部分数据附在下面。第五列和第六列分别是lat和lon。

   0 C130  30-07-2018 20:07   43.53 -116.16  887.60    887.598
   1 C130  30-07-2018 20:08   43.49 -116.17  860.73    860.733
   2 C130  30-07-2018 20:09   43.45 -116.23  832.14    832.143
   3 C130  30-07-2018 20:10   43.42 -116.29  798.53    798.529
   4 C130  30-07-2018 20:11   43.39 -116.36  769.36    769.359
   5 C130  30-07-2018 20:12   43.38 -116.44  744.33    744.332
   6 C130  30-07-2018 20:13   43.37 -116.52  713.75    713.749
   7 C130  30-07-2018 20:14   43.37 -116.60  682.41    682.406
   8 C130  30-07-2018 20:15   43.38 -116.68  658.94    658.943
   9 C130  30-07-2018 20:16   43.40 -116.76  634.47    634.471
  10 C130  30-07-2018 20:17   43.39 -116.83  611.09    611.085
  11 C130  30-07-2018 20:18   43.34 -116.86  591.79    591.791
  12 C130  30-07-2018 20:19   43.28 -116.88  572.06    572.057
  13 C130  30-07-2018 20:20   43.23 -116.90  554.59    554.594
  14 C130  30-07-2018 20:21   43.16 -116.92  551.53    551.532
  15 C130  30-07-2018 20:22   43.11 -116.98  551.75    551.745
  16 C130  30-07-2018 20:23   43.07 -117.05  551.64    551.641
  17 C130  30-07-2018 20:24   43.03 -117.12  551.55    551.545
  18 C130  30-07-2018 20:25   42.98 -117.19  551.49    551.486
  19 C130  30-07-2018 20:26   42.94 -117.27  551.45    551.448

所以我处理了数据之后。我提取位置。并获取如下所示的原始数据。第一列是lat,第二列是lon。

[[  43.53 -116.16]
[  43.49 -116.17]
[  43.45 -116.23]
[  43.42 -116.29]
[  43.39 -116.36]
[  43.38 -116.44]
[  43.37 -116.52]
[  43.37 -116.6 ]
[  43.38 -116.68]
[  43.4  -116.76]
...]

我有这样的例行程序enter image description here但是我想使用Cartopy将其绘制在地球物理地图上。

但是我不知道。

您能给我一些建议吗?

Lixu

python matplotlib matplotlib-basemap flightpath
1个回答
0
投票

您可以查看Cartopy文档,可以使用许多简单的示例来构建自己的地图,我建议您从gallery开始。为了绘制您的数据,我创建了以下示例:

import cartopy.crs as ccrs
import cartopy.feature as cfeature

#Create latitude and longitude data
lat=np.array([43.53,43.49,43.45,43.42,43.39,43.38,43.37,43.37,43.38,43.4])
lon=np.array([-116.16,-116.17,-116.23,-116.29,-116.36,-116.44,-116.52,-116.6,-116.68,-116.76])

#define map extent
extent = [-130, -90, 30, 60]

#define state borders
states_borders = cfeature.NaturalEarthFeature(
        category='cultural',
        name='admin_0_countries',
        scale='50m',
        facecolor='none')

states_provinces = cfeature.NaturalEarthFeature(
        category='cultural',
        name='admin_1_states_provinces_lines',
        scale='50m',
        facecolor='none')


#create figure
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
#Add features
ax.add_feature(cfeature.LAND)
ax.add_feature(states_provinces, edgecolor='gray')
ax.add_feature(states_borders, edgecolor='black')
#plot data
ax.plot(lon,lat, 'o',transform=ccrs.PlateCarree())
ax.set_extent(extent)

plt.show()

产生以下图像:enter image description here

如果您想添加图层并生成更复杂的地图,则可以以此为基础。

© www.soinside.com 2019 - 2024. All rights reserved.