Python:如何在地图上绘制飞行轨迹/航线

2024-06-16 10:53:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试着用位置数据在地图上画出一条飞行路线。在

我得到了一份位置数据,其中还包括其他信息。部分数据附于下文。第五列和第六列分别是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。在

^{pr2}$

我有这样的惯例 enter image description here 但我想用卡通画在地球物理图上。在

但我想不通。在

你能给我一些建议吗?在

李旭


Tags: 数据信息原始数据地图路线建议lonlat
1条回答
网友
1楼 · 发布于 2024-06-16 10:53:58

你可以看看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

如果你想添加图层并生成更复杂的地图,你可以在这个基础上开始构建。在

相关问题 更多 >