Geography Reference
In-Depth Information
To begin, we will create a rules file to define colors by percentage of the
range of elevations in the raster. The rules file specifies percentages and
a color in RGB notation and is taken directly from the manual page for
r.colors .
0% 0 230 0
20% 0 160 0
35% 50 130 0
55% 120 100 30
75% 120 130 40
90% 170 160 50
100% 255 255 100
We save this as myelevation.rules and will use it in a minute. To create
the colored hillshade, we set the colors for the DEM to those in the rules
file we just built and then do some magic with the r.his and r.composite
commands. Here is a script that does the whole process for us:
#!/bin/sh
Line 1
r.shaded.relief map=ancc6_dem shadedmap=ancc6_shade zmult=4 --overwrite
-
cat myelevation.rules |r.colors map=ancc6_dem color=rules
-
r.his -n h_map=ancc6_dem i_map=ancc6_shade r_map=ancc6_r g_map=ancc6_g \
-
b_map=ancc6_b --overwrite
5
r.composite -d red=ancc6_r blue=ancc6_b green=ancc6_g output=ancc6_comb \
-
--overwrite
-
Let's take a look at each line of the script to see what it does. Line 2 cre-
ates the shaded relief map from the DEM, with a vertical exaggeration
of 4. We specified the --overwrite option (you can also use --o ) to allow
us to run the script multiple times if need be, replacing the existing
shaded relief map each time.
On line 3, we apply the color rules to the DEM by piping the contents
of the rules file to the r.colors command. Now for the tricky part.
Next we use r.his to create red, green, and blue maps from the DEM
and shaded relief as shown on line 4. The hue is taken from the input
DEM and specified with the h_map parameter. This sets the color for
each cell. The intensity or brightness of each cell is set from the shaded
relief map using the i_map parameter. The remainder of line 4 contains
the names for the output of the red, green, and blue maps.
Finally on line 6, we put the RGB maps back together with r.composite to
create the final map named ancc6_comb . Now we have a nicely colored
hillshade, as shown in Figure 10.4 , on the next page.
You may be wondering about the value of the composite map we just
created. Apart from displaying it in GRASS or QGIS, we can export it
 
Search WWH ::




Custom Search