Plot Fine Grained Geodesic with Cartopy

匆匆过客 提交于 2021-01-29 08:49:46

问题


The following code (copied from here) produces a nicely looking geodesic between NYC and New Delhi. Upon close inspection, the geodesic does not look smooth. How can I make it smooth looking?

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


回答1:


You need to set a finer threshold of the line segments along the plotted geodesic line. Here is the relevant lines of code to do so.

plateCr = ccrs.PlateCarree()
# print(plateCr._threshold) # original threshold=0.5
plateCr._threshold = plateCr._threshold/10.  #set finer threshold
ax = plt.axes(projection=plateCr)

Replace the line:

ax = plt.axes(projection=ccrs.PlateCarree())

with the proposed code above. The result plot should look like this:



来源:https://stackoverflow.com/questions/60685245/plot-fine-grained-geodesic-with-cartopy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!