Before you start to draw maps with python, you first need to install basemap and pyshp. Click here to see how to install basemap . And the following command to install pyshp
1
pip install pyshp --user
Draw maps
Since basemap is a plug-in in Python, so we first new a py file.
World map with coastlines
1 2 3 4 5 6 7 8
import matplotlib.pyplot as plot from mpl_toolkits.basemap import Basemap
plot.figure(figsize=(16,8)) m = Basemap() m.drawcoastlines()
plot.show()
World map with countries
1 2 3 4 5 6 7 8 9
import matplotlib.pyplot as plot from mpl_toolkits.basemap import Basemap
plot.figure(figsize=(14,6)) m = Basemap() m.drawcoastlines() m.drawcountries(linewidth=1) plot.show()
Chinese map board
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import matplotlib.pyplot as plot from mpl_toolkits.basemap import Basemap