I am trying to plot a flight routine on map with location data.
I got a position data which also include other information. Part of data is attached below. The fifth column and sixth column are lat and lon respectively.
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
So After I process the data. I get extract the location. And get rawdata like below. The first column is lat and the second is 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]
...]
I got a routine like this But I want to plot it on a geophysical map using cartopy.
But I could not figure it out.
Could you please give me some suggestions?
Lixu
You can look at Cartopy documentation, there are lot of simple examples that you could use to build your own map, I would recommend you to start from the gallery . To plot your data I created the following example:
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()
that produces the following image:
you can start to build on this if you want to add layers and produce more complicated maps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.