⛰️ DEM Hillshade ---------------- Generate hillshade map from Digital Elevation Model (DEM). A hillshade is a 3D representation of a surface where the darker and lighter colors represent the shadows and highlights that you would visually expect to see in a terrain model. Hillshades are often used as an underlay in a map, to make the data appear more 3-Dimensional. .. note:: This example was adopted from `EarthPy `_ .. code:: python from localtileserver import TileClient, get_leaflet_tile_layer from localtileserver import examples, helpers from ipyleaflet import Map, SplitMapControl import rasterio # Example DEM dataset client = examples.get_co_elevation() tdem = get_leaflet_tile_layer(client, colormap='gist_earth') m = Map(center=client.center(), zoom=client.default_zoom) m.add(tdem) m Read the DEM data as a NumPy array using rasterio: .. code:: python dem = client.dataset.read()[0, :, :] dem.shape Compute the hillshade of the DEM using the :func:`localtileserver.helpers.hillshade` function (adopted from EarthPy). .. code:: python help(helpers.hillshade) .. code:: python # Compute hillshade hs_arr = helpers.hillshade(dem) # Save hillshade arrays as new raster and open with rasterio hs = rasterio.open(helpers.save_new_raster(client, hs_arr)) .. code:: python # Make an ipyleaflet tile layer of the hillshade hst = get_leaflet_tile_layer(hs) m = Map(center=client.center(), zoom=client.default_zoom) control = SplitMapControl(left_layer=tdem, right_layer=hst) m.add_control(control) m .. image:: https://raw.githubusercontent.com/banesullivan/localtileserver/main/imgs/hillshade_compare.png We can also overlay the hillshade on the original DEM so that it gives it a 3D effect: .. code:: python m = Map(center=client.center(), zoom=client.default_zoom) m.add(tdem) m.add(get_leaflet_tile_layer(hs, opacity=0.5)) m .. image:: https://raw.githubusercontent.com/banesullivan/localtileserver/main/imgs/hillshade.png