Topographic Hillshading#

Download this notebook from GitHub (right-click to download).


Most examples work across multiple plotting backends, this example is also available for:

import holoviews as hv
from holoviews import opts

Define data#

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.cbook import get_sample_data
from matplotlib.colors import LightSource

dem = get_sample_data('jacksboro_fault_dem.npz')
z = dem['elevation']

dx, dy = dem['dx'], dem['dy']
dy = 111200 * dy
dx = 111200 * dx * np.cos(np.radians(dem['ymin']))

# Shade from the northwest, with the sun 45 degrees from horizontal
ls = LightSource(azdeg=315, altdeg=45)
cmap =

# Vary vertical exaggeration and blend mode and plot all combinations
grid = hv.GridMatrix(kdims=['Vertical exaggeration', 'Blend mode', ])
for ve in [0.1, 1, 10]:
    # Show the hillshade intensity image in the first row
    grid['None', ve] = hv.Image(ls.hillshade(z, vert_exag=ve, dx=dx, dy=dy))
    # Place hillshaded plots with different blend modes in the rest of the rows
    for mode in ['hsv', 'overlay', 'soft']:
        rgb = ls.shade(z, cmap=cmap, blend_mode=mode,
                       vert_exag=ve, dx=dx, dy=dy)
        grid[mode, ve] = hv.RGB(rgb)


    opts.GridMatrix(xaxis='bottom', yaxis='left', shared_xaxis=False, shared_yaxis=False),