I am trying to plot a great circle distance between two points. I have found an in the cartopy docs (introductory_examples/01.great_circle.html):
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
ax = plt.axes(projection=ccrs.Robinson())
ax.set_global()
ax.coastlines()
plt.plot([-0.08, 132], [51.53, 43.17], color='red', transform=ccrs.Geodetic())
plt.plot([-0.08, 132], [51.53, 43.17], color='blue', transform=ccrs.PlateCarree())
plt.show()
which makes the following image:
The thing is, in my own work, the two points are much closer together, and in a different projection (though I think that isn't important here). If I change this code to be a line in a smaller area, like so:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
ax = plt.axes(projection=ccrs.Robinson())
ax.set_extent([-5, 55, 40, 55])
ax.coastlines()
plt.plot([-0.08, 50], [51.53, 43.17], color='red', transform=ccrs.Geodetic())
plt.plot([-0.08, 50], [51.53, 43.17], color='blue', transform=ccrs.PlateCarree())
plt.show()
This makes the following image:
The red great circle line in this case looks crappy and looks like it is due to being too low resolution. How do I increase the number of points making up the great circle line?
This problem is due to the hard-coded threshold in the projection. Currently this is not a user controllable parameter, but you can work around that by defining your own sub-class:
class LowerThresholdRobinson(ccrs.Robinson):
@property
def threshold(self):
return 1e3
If you use LowerThresholdRobinson()
instead of ccrs.Robinson()
when defining the axes this should eliminate the problem.