In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
import numpy as np
In [3]:
from mpl_toolkits.basemap import Basemap as Basemap
Using the Basemap module, we are able to draw the earth.
In [4]:
plt.figure(figsize=(14,8))
Map = Basemap()
Map.drawcoastlines()
Map.drawcountries()
Map.drawmapboundary()
Map.fillcontinents(color = 'coral')
plt.show()
Example from: Cameron Cooke's "The Big Picture"
In [5]:
Map = Basemap(projection='ortho', lat_0=49, lon_0=-123, resolution='l')
# draw coastlines, country boundaries, fill continents.
Map.drawcoastlines(linewidth=0.25)
Map.drawcountries(linewidth=0.25)
Map.fillcontinents()
# draw the edge of the map projection region (the projection limb)
Map.drawmapboundary()
# draw lat/lon grid lines every 30 degrees.
Map.drawmeridians(np.arange(0,360,30))
Map.drawparallels(np.arange(-90,90,30))
plt.show()
In [7]:
# Coordinates for Vancouver, BC
Van_lon = -123.1207
Van_lat = 49.2827
The following code is based off of Bill Mill's "Simple maps in Python"
In [34]:
plt.figure(figsize=(20,10))
Map = Basemap(
projection='merc', resolution='h', area_thresh=0.1,
lat_0=Van_lat, lon_0=Van_lon,
llcrnrlat=Van_lat-1.5, llcrnrlon=Van_lon-1.25,
urcrnrlat=Van_lat+1.5, urcrnrlon=Van_lon+2
)
# draw coastlines, country boundaries, fill continents.
Map.drawcoastlines(linewidth=0.25)
Map.drawcountries(linewidth=0.25)
Map.fillcontinents()
# draw the edge of the map projection region (the projection limb)
Map.drawmapboundary()
# draw rivers
Map.drawrivers(color='b', linewidth=1)
# draw lat/lon grid lines
Map.drawmeridians([int(Van_lon+i) for i in range(-1,3,)], labels=[1,0,0,1])
Map.drawparallels([int(Van_lat+i) for i in range(-1,3,)], labels=[1,0,0,1])
# label Vancouver
x,y = Map(Van_lon, Van_lat)
Map.plot(x, y, 'r*', markersize=24)
plt.annotate('Vancouver', xy=(x,y), xytext=(10,10), textcoords='offset points', fontsize=16)
plt.show()