Menu

[r4312]: / trunk / toolkits / basemap / examples / ireland.py  Maximize  Restore  History

Download this file

145 lines (138 with data), 4.6 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from matplotlib.toolkits.basemap import Basemap, basemap_datadir
from pylab import show, title, arange, figure, draw, ion, ioff, clf
import cPickle, time, sys, os
# turn interactive mode on.
ion()
# create new figure
fig=figure()
# create Basemap instance. Use 'crude' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='c',projection='tmerc',lon_0=-8.,lat_0=0.)
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw political boundaries.
m.drawcountries()
# draw parallels
circles = arange(50,60,1).tolist()
m.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
meridians = arange(-12,0,1)
m.drawmeridians(meridians,labels=[0,0,1,1])
print 'plotting with crude res boundaries ...'
title("Crude Res Boundaries ('c')",y=1.05)
draw()
time.sleep(5)
# create new figure
#fig=figure()
clf()
# create Basemap instance. Use 'low' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='l',projection='tmerc',lon_0=-8.,lat_0=0.)
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw political boundaries.
m.drawcountries()
# draw parallels
m.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
m.drawmeridians(meridians,labels=[0,0,1,1])
print 'plotting with low res boundaries ...'
title("Low Res Boundaries ('l')",y=1.05)
draw()
time.sleep(5)
t1 = time.clock()
# create new figure
#fig=figure()
clf()
print 'plotting with intermediate res boundaries ...'
# create Basemap instance. Use 'intermediate' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='i',projection='tmerc',lon_0=-8.,lat_0=0.)
print time.clock()-t1,'seconds to create class instance with intermediate res coastlines'
# cPickle the class instance.
cPickle.dump(m,open('map.pickle','wb'),-1)
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw political boundaries.
m.drawcountries()
# draw parallels
m.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
m.drawmeridians(meridians,labels=[0,0,1,1])
title("Intermediate Res Boundaries ('i')",y=1.05)
draw()
time.sleep(5)
# create new figure
#fig=figure()
clf()
# read cPickle back in and plot it again (should be much faster).
t1 = time.clock()
m2 = cPickle.load(open('map.pickle','rb'))
print time.clock()-t1,' to read the intermediate res coastline class instance back in from a cPickle'
# draw coastlines and fill continents.
m2.drawcoastlines()
m2.fillcontinents()
# draw political boundaries.
m2.drawcountries(linewidth=1.0)
# draw major rivers.
m2.drawrivers(color='b')
# draw parallels
m2.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
m2.drawmeridians(meridians,labels=[0,0,1,1])
print 'plotting with intermediate res boundaries from a saved pickle ...'
title("Intermediate Res Boundaries ('i') with major rivers",y=1.05)
draw()
time.sleep(5)
# only do high-res coastlines if they are installed, otherwise stop here.
if not os.path.isfile(os.path.join(basemap_datadir,'gshhs_h.txt')):
sys.exit(0)
import time
t1 = time.clock()
# create new figure
#fig=figure()
clf()
print 'plotting with high res boundaries ...'
# create Basemap instance. Use 'high' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='h',projection='tmerc',lon_0=-8.,lat_0=0.)
print time.clock()-t1,'seconds to create class instance with high res coastlines'
# cPickle the class instance.
cPickle.dump(m,open('map.pickle','wb'),-1)
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw political boundaries.
m.drawcountries()
# draw parallels
m.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
m.drawmeridians(meridians,labels=[0,0,1,1])
title("High Res Boundaries ('i')",y=1.05)
draw()
time.sleep(5)
# create new figure
#fig=figure()
clf()
# read cPickle back in and plot it again (should be much faster).
t1 = time.clock()
m2 = cPickle.load(open('map.pickle','rb'))
print time.clock()-t1,' to read the high res coastline class instance back in from a cPickle'
# draw coastlines and fill continents.
m2.drawcoastlines()
m2.fillcontinents()
# draw political boundaries.
m2.drawcountries(linewidth=1.0)
# draw major rivers.
m2.drawrivers(color='b')
# draw parallels
m2.drawparallels(circles,labels=[1,1,0,0])
# draw meridians
m2.drawmeridians(meridians,labels=[0,0,1,1])
print 'plotting with high res boundaries from a saved pickle ...'
title("High Res Boundaries ('i') with major rivers",y=1.05)
ioff()
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.