-
Notifications
You must be signed in to change notification settings - Fork 20
/
make-hillshades.sh
executable file
·28 lines (20 loc) · 1.27 KB
/
make-hillshades.sh
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
#!/bin/bash
# Takes a Digital Elevation Model (DEM) and generates hillshades from 4 different light angles and a slope shade
# These may then be composited in QGIS, TileMill, Photoshop, etc.
# Note: Process DEM prior to running this script (mosaic, clip, resample, reproject, etc)
GFLT=$1 #must be a raster DEM file type supported by GDAL
Z=1.3 # vertical exaggeration factor. apply greater value for smaller scale / larger areas
echo "Generating hillshade from $GFLT with sunlight angle at 45˚..."
gdaldem hillshade -of 'GTiff' -z $Z -az 45 $GFLT hillshade_az45.tif
echo "Generating hillshade from $GFLT -z $Z with sunlight angle at 135˚..."
gdaldem hillshade -of 'GTiff' -z $Z -az 135 $GFLT hillshade_az135.tif
echo "Generating hillshade from $GFLT -z $Z with sunlight angle at 225˚..."
gdaldem hillshade -of 'GTiff' -z $Z -az 225 $GFLT hillshade_az225.tif
echo "Generating hillshade from $GFLT -z $Z with sunlight angle at 315˚..."
gdaldem hillshade -of 'GTiff' -z $Z -az 315 $GFLT hillshade_az315.tif
echo "Generating Slope from $GFLT..."
gdaldem slope $GFLT slope.tif
echo "Making color-slope.txt..."
touch color-slope.txt && printf '%s\n%s\n' '0 255 255 255' '90 0 0 0' >> color-slope.txt
echo "Creating slope shade..."
gdaldem color-relief slope.tif color-slope.txt slopeshade.tif