我现在想在Cartopy中画一个扇形的楔形图,所以我查找matplotlib.patches.Wedge方法。它几乎是我需要的函数,但是它所需要的参数radius的单位是度,而不是公里。有没有办法用公里而不是度来表示matplotlib.patches.Wedge方法?
谢谢。
发布于 2020-09-01 19:40:23
我猜你说的是“而不是学位”意味着你在伦敦/洛杉矶的工作岗位。最简单的方法是将你的龙/拉特中心点转换成地图上的一个位置。在绘制图时,我们还将使用半径(以米为单位):
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge
import cartopy.crs as ccrs
proj = ccrs.LambertConformal()
latlon_proj = ccrs.PlateCarree()
lat = 18
lon = 140
radius = 500 # In km
x, y = proj.transform_point(lon, lat, src_crs=latlon_proj)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=proj)
ax.plot(x, y, 'ro')
# Here we need to convert radius to meters
ax.add_patch(Wedge((x, y), r=radius * 1000, theta1=0, theta2=90))
ax.coastlines()https://stackoverflow.com/questions/63679841
复制相似问题