NAME

shade.clr.sh - Creates a color shaded relief map based on current resolution settings and sun altitude and color azimuths values entered by the user.
(GRASS Shell Script)

SYNOPSIS

shade.clr.sh
shade.clr.sh help
shade.clr.sh
[altitude=value] [r_azimuth=value] [g_azimuth=value] [b_azimuth=value] [elevation=name] [shade=value|m|f]

DESCRIPTION

shade.clr.sh is a Bourne shell (sh(1)) script that creates a colored raster shaded relief map based on current resolution settings and on sun altitude and color light azimuth values entered by the user. The new shaded relief map is named <elevation>.shade and stored in the user's current mapset.

If no parameters are provided on startup, this program is interactive; thus if the user enters the command:

shade.clr.sh
The program then prompts the user to enter values for:
  1. The altitude of the sun in degrees above the horizon (a value between 0 and 90 degrees), and
  2. The azimuth of the red, green, and blue lights in degrees to the east of north (a value between -1 and 360 degrees).
  3. The name of a raster map layer whose cell category values are to provide elevation values for the shaded relief map. Typically, this would be a map layer of elevation; however, any raster map layer can be named.
  4. The scaling parameter, which compensates for a different horizontal scale than vertical scale. For example, when a latitude-longitude projection is used with an elevation map measured in meters. If 'scale' is a number then the ewres and nsres are multiplied by that scale to calculate the shading. If 'scale' is the letter M (either case) the number of meters in a degree of latitude is used as the scale. If 'scale' is the letter F (either case) then the number of feet in a degree is used. The script scales latitude and longitude equally, so it's only approximately right, but for shading its close enough. It makes the difference between a usable and unusable shade.
Specifically, shade.clr.sh executes the following r.mapcalc statement:
r.mapcalc << EOF
$ELEV.shade = eval( \\
x=($elev[-1,-1] + 2.*$elev[0,-1] + $elev[1,-1] \\
-$elev[-1,1] - 2.*$elev[0,1] - $elev[1,1])/(8.*ewres()*$shade) , \\
y=($elev[-1,-1] + 2.*$elev[-1,0] + $elev[-1,1] \\
-$elev[1,-1] - 2.*$elev[1,0] - $elev[1,1])/(8.* nsres()*$shade) , \\
slope=90.-atan(sqrt(x*x + y*y)), \\
a=round(atan(x,y)), \\
a=if(isnull(a),1,a), \\
aspect=if(x!=0||y!=0,if(a,a,360.)), \\
rang = sin($alt)*sin(slope) + cos($alt)*cos(slope) * cos($raz-aspect),\\
red = int(if(rang < 0.,0.,4.9*rang)), \\
gang = sin($alt)*sin(slope) + cos($alt)*cos(slope) * cos($gaz-aspect),\\
green = int(if(gang < 0.,0.,4.9*gang)), \\
bang = sin($alt)*sin(slope) + cos($alt)*cos(slope) * cos($baz-aspect), \\
blue = int(if(bang < 0.,0.,4.9*bang)), \\
1. + red + 5. * green + 25. * blue )
EOF

Refer to the manual entry for r.mapcalc for an explanation of the filtering syntax shown in the above expression. See, for example, the section on "The Neighborhood Modifier".

shade.clr.sh then runs r.colors to assign a color table to the new shaded relief map <elevation>.shade.

FILES

This program is simply a shell script. Users are encouraged to make their own shell scripts using similar techniques. See $GISBASE/scripts/shade.clr.sh.

SEE ALSO

An Algebra for GIS and Image Processing, by Michael Shapiro and Jim Westervelt, U.S. Army Construction Engineering Research Laboratory (March/1991) (get from GRASS web site).

shade.rel.sh
blend.sh
g.ask
g.region
r.colors
r.mapcalc

AUTHOR

Jim Westervelt, U.S. Army Construction Engineering Research Laboratory

Last changed: $Date: 2003/08/26 02:11:16 $