Minimal Geodetic example using Cartopy
This minimal example shows you how to plot a geodetic line between two points. It is closely based on the cartopy with matplotlib intro.
import cartopy.crs as ccrs
import cartopy.feature as cf
from matplotlib import pyplot as plt
ax = plt.axes(projection = ccrs.Mollweide())
ax.stock_img()
ax.add_feature(cf.BORDERS)
# Add geodetic between two points
# Format: plot([lon1, lon2], [lat1, lat2])
plt.plot([-75, 77.23], [43, 28.61],
color='blue', linewidth=2,
transform=ccrs.Geodetic()
)
Complete example code
This code reproduces the image shown above:
import cartopy.crs as ccrs
import cartopy.feature as cf
ax = plt.axes(projection = ccrs.Mollweide())
ax.stock_img()
ax.add_feature(cf.BORDERS)
# Add geodetic between two points
# Format: plot([lon1, lon2], [lat1, lat2])
plt.plot([-75, 77.23], [43, 28.61],
color='blue', linewidth=2,
transform=ccrs.Geodetic()
)
# Make figure larger
plt.gcf().set_size_inches(20, 10)
# Save figure as SVG
plt.savefig("Cartopy-Geodetic.svg")