Menu

[r5495]: / trunk / toolkits / basemap / examples / plot_tissot.py  Maximize  Restore  History

Download this file

101 lines (93 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap
from matplotlib.patches import Polygon
# Tissot's Indicatrix (http://en.wikipedia.org/wiki/Tissot's_Indicatrix).
# These diagrams illustrate the distortion inherent in all map projections.
# In conformal projections, where angles are conserved around every location,
# the Tissot's indicatrix are all circles, with varying sizes. In equal-area
# projections, where area proportions between objects are conserved, the
# Tissot's indicatrix have all unit area, although their shapes and
# orientations vary with location.
# adapted from http://www.perrygeo.net/wordpress/?p=4
# create new figure
fig=plt.figure()
m = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80,
projection='cyl')
shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
ax = plt.gca()
for nshape,seg in enumerate(m.tissot):
poly = Polygon(seg,facecolor='green',zorder=10)
ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
m.drawcoastlines()
m.fillcontinents()
plt.title('Tissot Diagram - Cylindrical Equal Area')
print 'plot Cylindrical Equidistant Equal Area Tissot diagram ...'
# create new figure
fig=plt.figure()
m = Basemap(llcrnrlon=-180,llcrnrlat=-70,urcrnrlon=180,urcrnrlat=70,
projection='merc',lat_ts=20)
shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
ax = plt.gca()
for nshape,seg in enumerate(m.tissot):
poly = Polygon(seg,facecolor='green',zorder=10)
ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
m.drawcoastlines()
m.fillcontinents()
plt.title('Tissot Diagram - Mercator Conformal')
print 'plot Mercator Conformal Tissot diagram ...'
# create new figure
fig=plt.figure()
m = Basemap(lon_0=-60,lat_0=45,projection='ortho')
shp_info = m.readshapefile('tissot','tissot',drawbounds=False)
ax = plt.gca()
for nshape,seg in enumerate(m.tissot):
xx,yy = zip(*seg)
if max(xx) < 1.e20 and max(yy) < 1.e20:
poly = Polygon(seg,facecolor='green',zorder=10)
ax.add_patch(poly)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-90,91,30))
m.drawmeridians(np.arange(-180,180,30))
plt.title('Tissot Diagram - Orthographic')
m.drawmapboundary()
plt.gca().set_frame_on(True)
print 'plot Orthographic Tissot diagram ...'
# create new figure
fig=plt.figure()
m = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='npstere')
shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
ax = plt.gca()
for nshape,seg in enumerate(m.tissot):
poly = Polygon(seg,facecolor='green',zorder=10)
ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1])
m.drawcoastlines()
m.fillcontinents()
plt.title('Tissot Diagram - North Polar Stereographic Conformal')
print 'plot North Polar Stereographic Conformal Tissot diagram ...'
# create new figure
fig=plt.figure()
m = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='nplaea')
shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
ax = plt.gca()
for nshape,seg in enumerate(m.tissot):
poly = Polygon(seg,facecolor='green',zorder=10)
ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1])
m.drawcoastlines()
m.fillcontinents()
plt.title('Tissot Diagram - North Polar Lambert Azimuthal Equal Area')
print 'plot North Polar Lambert Azimuthal Equal Area Tissot diagram ...'
plt.show()