Skip to content

Commit d873075

Browse files
author
Jeff Whitaker
committed
add etopo1 method
1 parent be229f2 commit d873075

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
version 1.0.2 (not yet released)
22
* change default land-sea mask (now 2.5 minute resolution).
3+
* add etopo method (similar to bluemarble, but plots etopo
4+
relief image from www.ngdc.noaa.gov/mgg/global as a map background).
35
* add shadedrelief method (similar to bluemarble, but plots shaded
46
relief image from naturalearthdata.com as a map background).
57
* replace pyshapelib with pure python shapelib.py from

examples/wiki_example.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@
3636
x, y = map(lons*180./np.pi, lats*180./np.pi)
3737
# contour data over the map.
3838
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
39+
plt.title('filled continent background')
40+
41+
# as above, but use land-sea mask image as map background.
42+
fig = plt.figure()
43+
map.drawmapboundary()
44+
map.drawmeridians(np.arange(0,360,30))
45+
map.drawparallels(np.arange(-90,90,30))
46+
# plot filled circles at the locations of the cities.
47+
map.plot(xc,yc,'wo')
48+
# plot the names of five cities.
49+
for name,xpt,ypt in zip(cities,xc,yc):
50+
plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w')
51+
# contour data over the map.
52+
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
53+
plt.title('land-sea mask background')
54+
map.drawlsmask(ocean_color='aqua',land_color='coral')
3955

4056
# as above, but use blue marble image as map background.
4157
fig = plt.figure()
@@ -49,6 +65,37 @@
4965
plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w')
5066
# contour data over the map.
5167
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
52-
# draw shaded relief image in background.
68+
plt.title('blue marble background')
69+
map.bluemarble()
70+
71+
# as above, but use shaded relief image as map background.
72+
fig = plt.figure()
73+
map.drawmapboundary()
74+
map.drawmeridians(np.arange(0,360,30))
75+
map.drawparallels(np.arange(-90,90,30))
76+
# plot filled circles at the locations of the cities.
77+
map.plot(xc,yc,'wo')
78+
# plot the names of five cities.
79+
for name,xpt,ypt in zip(cities,xc,yc):
80+
plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w')
81+
# contour data over the map.
82+
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
83+
plt.title('shaded relief background')
5384
map.shadedrelief()
85+
86+
# as above, but use etopo image as map background.
87+
fig = plt.figure()
88+
map.drawmapboundary()
89+
map.drawmeridians(np.arange(0,360,30))
90+
map.drawparallels(np.arange(-90,90,30))
91+
# plot filled circles at the locations of the cities.
92+
map.plot(xc,yc,'wo')
93+
# plot the names of five cities.
94+
for name,xpt,ypt in zip(cities,xc,yc):
95+
plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w')
96+
# contour data over the map.
97+
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
98+
plt.title('etopo background')
99+
map.etopo()
100+
54101
plt.show()

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,24 @@ def shadedrelief(self,ax=None,scale=None,**kwargs):
33093309
else:
33103310
return self.warpimage(image='shadedrelief',scale=scale,**kwargs)
33113311

3312+
def etopo(self,ax=None,scale=None,**kwargs):
3313+
"""
3314+
display etopo relief image (from
3315+
http://www.ngdc.noaa.gov/mgg/global/global.html)
3316+
as map background.
3317+
Default image size is 5400x2700, which can be quite slow and
3318+
use quite a bit of memory. The ``scale`` keyword can be used
3319+
to downsample the image (``scale=0.5`` downsamples to 5400x2700).
3320+
3321+
\**kwargs passed on to :meth:`imshow`.
3322+
3323+
returns a matplotlib.image.AxesImage instance.
3324+
"""
3325+
if ax is not None:
3326+
return self.warpimage(image='etopo',ax=ax,scale=scale,**kwargs)
3327+
else:
3328+
return self.warpimage(image='etopo',scale=scale,**kwargs)
3329+
33123330
def warpimage(self,image="bluemarble",scale=None,**kwargs):
33133331
"""
33143332
Display an image (filename given by ``image`` keyword) as a map background.
@@ -3343,10 +3361,14 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
33433361
# from NASA (http://visibleearth.nasa.gov).
33443362
if image == "bluemarble":
33453363
file = os.path.join(basemap_datadir,'bmng.jpg')
3346-
# display shadedrelief image (from
3347-
# http://www.ngdc.noaa.gov/mgg/image/globalimages.html)
3364+
# display shaded relief image (from
3365+
# http://www.shadedreliefdata.com)
33483366
elif image == "shadedrelief":
33493367
file = os.path.join(basemap_datadir,'shadedrelief.jpg')
3368+
# display etopo image (from
3369+
# http://www.ngdc.noaa.gov/mgg/image/globalimages.html)
3370+
elif image == "etopo":
3371+
file = os.path.join(basemap_datadir,'etopo1.jpg')
33503372
else:
33513373
file = image
33523374
# if image is same as previous invocation, used cached data.
1.28 MB
Loading

0 commit comments

Comments
 (0)