用Matplotlib底图在距指定点很大的圆距离内绘制阴影区域

问题描述 投票:0回答:1

我想使用Python / Matplotlib / Basemap绘制地图并为位于指定点给定距离内的圆加阴影,类似于此(由Great Circle Mapper生成的地图-版权所有©Karl L. Swartz。) :

enter image description here

我可以按如下方式生成地图:

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()

生成地图:

enter image description here

现在,我想在指定点(例如顶部地图)周围创建一个大圆。

我的尝试是使用一个地图对象,一个中心坐标对和一个距离,然后创建两条曲线,然后在它们之间绘制阴影的函数,例如:

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

我已经评论了我想做的事情,但不确定如何去做。

我已经尝试了几种方法,但是令我感到困惑的是,地图的所有输入都是以度为单位的坐标,而我想指定长度的点,并将其转换为纬度/经度点以进行绘图。我认为这与纬度/经度相对于地图投影坐标的数据有关。

任何朝着正确方向前进的人都会感激谢谢

python matplotlib matplotlib-basemap
1个回答
0
投票

最后,我必须手动执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.