Search code examples
pythonplotcartopy

Plot trajectories on cartopy by going as short as possible


I am using cartopy in python (Robinson card) I perfectly succeeded in displaying my world map as well as my points (from an oracle database). My goal would be to connect my dots in order to make trajectories. I also managed to display my trajectories but a problem arises. Indeed, when one of my points is on the far left of my map and the other is on the far right, my trajectory crosses my map instead of going through the "back" as it normally would on a globe. Can you help me ?


Solution

  • @bricos29, Did you use transform=ccrs.Geodetic() when plotting? I have tried the following code, it seems work fine.

    import matplotlib.pyplot as plt
    import cartopy.crs as ccrs
    ax = plt.axes(projection=ccrs.Robinson())
    ax.set_global()
    ax.coastlines()
    plt.plot([-120, 132], [51.53, 43.17], color='red',  transform=ccrs.Geodetic())
    plt.show()
    

    enter image description here