Thursday, October 12, 2017

Python easy earth globe

You can make a stunning earth globe, including topography and bathymetry, with just a few lines of python. Just now, I am interested in New Zealand, so we can put it in the middle. Here is the code:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
map = Basemap(projection='ortho', lat_0=-30, lon_0=170, resolution='l')
map.etopo()
map.drawcountries()
map.drawmeridians(np.arange(0,360,30))
map.drawparallels(np.arange(-90,90,30))
plt.show()

Below is the result, not bad for 9 lines of code!