如何以公里为单位设置标记大小?

How to set the markersize in kilometers?

我想圈某个点。圆的半径需要为 5 公里,但如何设置我的标记大小,使圆在地图上为 5 公里?

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap

width, height = 400000, 320000
ax=plt.figure(figsize=(20,10))

lonA =[2.631547,2.861595,2.931014]
latA =[51.120983,51.209122,51.238868]

m= Basemap(width=width,height=height,projection='lcc',
        resolution='h',lat_0=52.35,lon_0=4.5)

m.drawmapboundary(fill_color='turquoise')
m.fillcontinents(color='white',lake_color='aqua')
m.drawcountries(linestyle='--')

scatter2=m.scatter([], [], s=100, c='white', marker='o', label = 'Aurelia aurita', zorder=3, alpha=0.5,  edgecolor='steelblue')
z,a = m(lonA[0:3], latA[0:3])
scatter2.set_offsets(np.c_[z,a])

plt.show()

要以地图单位(米)绘制具有指定半径的圆,首先,我创建了一个函数 (genCircle2),它接受圆的输入参数和 returns 沿圆周长的点数组圆圈。在我下面的代码中,命令 m(lon,lat) 用于计算 (mx,my) 以米为单位的地图投影坐标。 命令 genCircle2(cx=mx, cy=my, rad=5000.) 计算圆绘图的点。这是工作代码。

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap

def genCircle2(cx=0, cy=0, rad=1):
    """Generate points along perimeters of a circle"""
    points = []
    segs = 20
    for ea in range(segs+1):
        xi = cx + rad*np.cos(ea*2.*np.pi/segs)
        yi = cy + rad*np.sin(ea*2.*np.pi/segs)
        points.append([xi,yi])
    return np.array(points)

width, height = 400000, 320000
ax = plt.figure(figsize=(12,10))

# long, lat
lonA = [2.631547, 2.861595, 2.931014]
latA = [51.120983, 51.209122, 51.238868]

# accompanying attributes, colors and ...
clrs = ['r', 'g', 'b']

m = Basemap(width=width, height=height, projection='lcc', \
        resolution='i', lat_0=52.35, lon_0=4.5)

m.drawmapboundary(fill_color='turquoise')
m.fillcontinents(color='white', lake_color='aqua')
m.drawcountries(linestyle='--')

# plot circles at points defined by (lonA,latA)
for lon,lat,clr in zip(lonA, latA, clrs):
    mx,my = m(lon,lat)                            # get map coordinates from (lon,lat)
    cclpnts = genCircle2(cx=mx, cy=my, rad=5000.) # get points along circle's perimeter
    m.plot(cclpnts[:,0], cclpnts[:,1], \
               label='Aurelia aurita', color=clr, \
               linewidth=0.75)           # plot circle

plt.show()

结果图: