用 Cartopy 绘制细粒度测地线
Plot Fine Grained Geodesic with Cartopy
以下代码(从 here 复制)生成纽约市和新德里之间的漂亮测地线。仔细检查后,测地线看起来并不平滑。我怎样才能使它看起来光滑?
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ny_lon, ny_lat = -75, 43
delhi_lon, delhi_lat = 77.23, 28.61
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat],
linewidth=2, marker='o', transform=ccrs.Geodetic())
plt.tight_layout()
plt.show()
您需要为绘制的测地线设置更精细的线段阈值。这是执行此操作的相关代码行。
plateCr = ccrs.PlateCarree()
# print(plateCr._threshold) # original threshold=0.5
plateCr._threshold = plateCr._threshold/10. #set finer threshold
ax = plt.axes(projection=plateCr)
替换行:
ax = plt.axes(projection=ccrs.PlateCarree())
使用上面建议的代码。结果图应如下所示:
以下代码(从 here 复制)生成纽约市和新德里之间的漂亮测地线。仔细检查后,测地线看起来并不平滑。我怎样才能使它看起来光滑?
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ny_lon, ny_lat = -75, 43
delhi_lon, delhi_lat = 77.23, 28.61
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat],
linewidth=2, marker='o', transform=ccrs.Geodetic())
plt.tight_layout()
plt.show()
您需要为绘制的测地线设置更精细的线段阈值。这是执行此操作的相关代码行。
plateCr = ccrs.PlateCarree()
# print(plateCr._threshold) # original threshold=0.5
plateCr._threshold = plateCr._threshold/10. #set finer threshold
ax = plt.axes(projection=plateCr)
替换行:
ax = plt.axes(projection=ccrs.PlateCarree())
使用上面建议的代码。结果图应如下所示: