>>> from env_helper import info; info()
页面更新时间: 2022-05-27 12:19:45
运行环境:
    Linux发行版本: Debian GNU/Linux bookworm/sid
    操作系统内核: Linux-5.16.18-200.fc35.x86_64-x86_64-with-glibc2.33
    Python版本: 3.10.4

17.6. 球面距离案例

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

17.6.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/sec7_demo_4_0.png