Menu

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

Download this file

80 lines (75 with data), 2.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
from matplotlib.toolkits.basemap import Basemap
from pylab import *
import cPickle
# create Basemap instance. Use 'crude' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=51.,urcrnrlon=-5.,urcrnrlat=56.,
resolution='c',area_thresh=1000.,projection='cyl')
# create figure with same aspect ratio as map.
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
fig.add_axes([0.1,0.1,0.8,0.8])
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw parallels
circles = arange(50,60,1).tolist()
m.drawparallels(circles,labels=[1,1,1,1])
# draw meridians
meridians = arange(-12,0,1)
m.drawmeridians(meridians,labels=[1,1,1,1])
title("Crude Res Coastlines ('c')",y=1.075)
show()
# create Basemap instance. Use 'low' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=51.,urcrnrlon=-5.,urcrnrlat=56.,
resolution='l',area_thresh=1000.,projection='cyl')
# create figure with same aspect ratio as map.
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
fig.add_axes([0.1,0.1,0.8,0.8])
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw parallels
m.drawparallels(circles,labels=[1,1,1,1])
# draw meridians
m.drawmeridians(meridians,labels=[1,1,1,1])
title("Low Res Coastlines ('l')",y=1.075)
show()
import time
t1 = time.clock()
# create Basemap instance. Use 'intermediate' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=51.,urcrnrlon=-5.,urcrnrlat=56.,
resolution='i',area_thresh=1000.,projection='cyl')
print time.clock()-t1,'seconds to create class instance with intermediate res coastlines'
# pickle the class instance.
cPickle.dump(m,open('map.pickle','wb'),-1)
# create figure with same aspect ratio as map.
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
fig.add_axes([0.1,0.1,0.8,0.8])
# draw coastlines and fill continents.
m.drawcoastlines()
m.fillcontinents()
# draw parallels
m.drawparallels(circles,labels=[1,1,1,1])
# draw meridians
m.drawmeridians(meridians,labels=[1,1,1,1])
title("Intermediate Res Coastlines ('i')",y=1.075)
show()
# read pickle back in and plot it again (should be much faster).
t1 = time.clock()
m2 = cPickle.load(open('map.pickle'))
print time.clock()-t1,' to read the intermediate res coastline class instance back in from a pickle'
# create figure with same aspect ratio as map.
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m2.aspect*xsize))
fig.add_axes([0.1,0.1,0.8,0.8])
# draw coastlines and fill continents.
m2.drawcoastlines()
m2.fillcontinents()
# draw parallels
m2.drawparallels(circles,labels=[1,1,1,1])
# draw meridians
m2.drawmeridians(meridians,labels=[1,1,1,1])
title("Intermediate Res Coastlines ('i')",y=1.075)
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.