目录

上一个主题

8.4. 使用数据

下一个主题

8.6. 自定义色彩映射

关注公众号


常见问题

  1. Windows下的安装说明
  2. Jupyter免费在线实验环境
  3. 勘误与补充


from helper import info; info()
页面更新时间: 2020-02-21 18:13:10
操作系统/OS: Linux-4.19.0-8-amd64-x86_64-with-debian-10.3 ;Python: 3.7.3

8.5. 球面距离案例

%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import os
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

8.5.1. 代码

my_map = Basemap(projection='merc', lat_0=38, lon_0=89,
                 resolution='h', area_thresh=0.1,
                 llcrnrlon=58, llcrnrlat=10,
                 urcrnrlon=143, urcrnrlat=55)

my_map.drawcoastlines()
# my_map.drawcountries()
my_map.fillcontinents(color='lightblue')
my_map.drawmapboundary()



lons = [125.352841, 87.6568,  73.052705]
lats = [43.903566,43.830036, 33.705168]
x, y = my_map(lons, lats)

labels = ['Changchun', 'Urumqi', 'Islamabad']
x_offsets = [250000] *3
y_offsets = [200000] * 3


# x, y = map(lons, lats)

# my_map.plot(x, y, marker=None,color='r')

my_map.plot(x, y, 'bo', markersize=10)

my_map.drawgreatcircle(125.352841, 43.903566, 87.6568, 43.830036, linewidth=2, color='c')
my_map.drawgreatcircle( 87.6568, 43.830036,73.052705,  33.705168, linewidth=2, color='c')

for label, xpt, ypt, x_offset, y_offset in zip(labels, x, y, x_offsets, y_offsets):
    plt.text(xpt + x_offset, ypt + y_offset, label, color='r')

plt.show()
_images/basemap-demo_4_0.png