1 Installation

Here, the platforms are windows 10 and Anaconda-3.5.3.0 (Python 3.7).

  • Open anaconda prompt type pip install geos to install library geos;
  • Go https://www.lfd.uci.edu/~gohlke/pythonlibs/ to download two libraries: pyproj‑2.6.1.post1‑cp37‑cp37m‑win_amd64.whl and basemap‑1.2.2‑cp37‑cp37m‑win_amd64.whl
  • Type commands: pip install pyproj‑2.6.1.post1‑cp37‑cp37m‑win_amd64.whl and pip install basemap‑1.2.2‑cp37‑cp37m‑win_amd64.whl

Now, we’ve installed Basemap and enjoy it!

2 The First Basemap

2.1 Satellite map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

# Set figure size.
plt.figure(figsize=(10, 5.5))

# Set map projection, and the center position.
bmap = Basemap(projection='cyl', lat_0=0, lon_0=0)

# Set the background as satellite map.
bmap.bluemarble()
plt.tight_layout()
plt.show()

01.png

2.2 Elevation model: etopo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

# Set figure size.
plt.figure(figsize=(10, 5.5))

# Set map projection, and the center position.
bmap = Basemap(projection='cyl', lat_0=0, lon_0=0)

# Set the background as satellite map.
bmap.etopo()
plt.tight_layout()
plt.show()

01.png

2.3 Shadedrelief

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

# Set figure size.
plt.figure(figsize=(10, 5.5))

# Set map projection, and the center position.
bmap = Basemap(projection='cyl', lat_0=0, lon_0=0)

# Set the background as satellite map.
bmap.shadedrelief()
plt.tight_layout()
plt.show()

03.png

3 Projections

3.1 Global range of the Earth

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

gproj = ['moll', 'cyl', 'aeqd', 'hammer', 'gall', 'vandg',
         'mbtfpq', 'robin', 'sinu', 'kav7', 'ortho', 'mill',
         'cea', 'vandg']

# Set figure size.
plt.figure(figsize=(15, 10))

for i in range(len(gproj)):
    plt.subplot(4, 4, i+1)
    # Set map projection, and the center position.
    bmap = Basemap(projection=gproj[i], lat_0=0, lon_0=0)
    bmap.drawcoastlines(color='gray', linewidth=1)
    plt.title(gproj[i], fontsize=15)
plt.tight_layout()
plt.show()

04.png