我想使用Python / Matplotlib / Basemap绘制地图并为位于指定点给定距离内的圆加阴影,类似于此(由Great Circle Mapper生成的地图-版权所有©Karl L. Swartz。 ):
我可以按如下方式生成地图:
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# create new figure,axes instances.
fig,ax = plt.subplots()
# setup Mercator map projection.
m = Basemap(
llcrnrlat=47.0,llcrnrlon=-126.62,urcrnrlat=50.60,urcrnrlon=-119.78,rsphere=(6378137.00,6356752.3142),resolution='i',projection='merc',lat_0=49.290,lon_0=-123.117,)
# Latitudes and longitudes of locations of interest
coords = dict()
coords['SEA'] = [47.450,-122.309]
# Plot markers and labels on map
for key in coords:
lon,lat = coords[key]
x,y = m(lat,lon)
m.plot(x,y,'bo',markersize=5)
plt.text(x+10000,y+5000,key,color='k')
# Draw in coastlines
m.drawcoastlines()
m.fillcontinents()
m.fillcontinents(color='grey',lake_color='aqua')
m.drawmapboundary(fill_color='aqua')
plt.show()
生成地图:
现在,我想在指定点(例如顶部地图)周围创建一个大圆圈。
我的尝试是一个函数,该函数获取地图对象,一个中心坐标对和一个距离,并创建两条曲线,然后在它们之间绘制阴影,例如:
def shaded_great_circle(map_,lat_0,lon_0,dist=100,alpha=0.2): # dist specified in nautical miles
dist = dist * 1852 # Convert distance to nautical miles
lat = np.linspace(lat_0-dist/2,lat_0+dist/2,50)
lon = # Somehow find these points
# Create curve for longitudes above lon_0
# Create curve for longitudes below lon_0
# Shade region between above two curves
我已在其中评论了我想做什么,但不确定如何做。
我尝试了几种方法,但是让我感到困惑的是,地图的所有输入都是以度为单位的坐标,而我想指定长度的点,并将其转换为纬度/经度情节。我认为这与纬度/经度相对于地图投影坐标的数据有关。
任何朝着正确方向前进的人都会受到赞赏 谢谢