#300 Draw a connection line with great circle

This page describe how to add a connection line between 2 places on a map with python and the basemap library. Here we represent the connection between New York and London. Note that the line is not straight: it is indeed the shortest route between these 2 cities, taking into account that the earth is a sphere. We call it a great circle, and it can be drawn with the drawgreatcircle function:

# libraries
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

# A basic map
m=Basemap(llcrnrlon=-100, llcrnrlat=20,urcrnrlon=30,urcrnrlat=70)
m.drawmapboundary(fill_color='#A6CAE0', linewidth=0)
m.fillcontinents(color='grey', alpha=0.7, lake_color='grey')
m.drawcoastlines(linewidth=0.1, color="white")

# Add a connection between new york and London
startlat = 40.78; startlon = -73.98
arrlat = 51.53; arrlon = 0.08
m.drawgreatcircle(startlon,startlat,arrlon,arrlat, linewidth=2, color='orange')

  • Sponsors

  • Leave a Reply

    Your email address will not be published.