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
| import numpy as np import matplotlib.pyplot as plt from matplotlib.cbook import get_sample_data from matplotlib.colors import LightSource
with np.load(get_sample_data('jacksboro_fault_dem.npz')) as dem: z = dem['elevation']
dx, dy = dem['dx'], dem['dy'] dy = 111200 * dy dx = 111200 * dx * np.cos(np.radians(dem['ymin']))
ls = LightSource(azdeg=315, altdeg=45) cmap = plt.cm.gist_earth
fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(8, 9)) plt.setp(axes.flat, xticks=[], yticks=[])
for col, ve in zip(axes.T, [0.1, 1, 10]): col[0].imshow(ls.hillshade(z, vert_exag=ve, dx=dx, dy=dy), cmap='gray')
for ax, mode in zip(col[1:], ['hsv', 'overlay', 'soft']): rgb = ls.shade(z, cmap=cmap, blend_mode=mode, vert_exag=ve, dx=dx, dy=dy) ax.imshow(rgb)
for ax, ve in zip(axes[0], [0.1, 1, 10]): ax.set_title('{0}'.format(ve), size=18) for ax, mode in zip(axes[:, 0], ['Hillshade', 'hsv', 'overlay', 'soft']): ax.set_ylabel(mode, size=18)
axes[0, 1].annotate('Vertical Exaggeration', (0.5, 1), xytext=(0, 30), textcoords='offset points', xycoords='axes fraction', ha='center', va='bottom', size=20) axes[2, 0].annotate('Blend Mode', (0, 0.5), xytext=(-30, 0), textcoords='offset points', xycoords='axes fraction', ha='right', va='center', size=20, rotation=90) fig.subplots_adjust(bottom=0.05, right=0.95)
plt.show()
|