NAME
shade.rel.sh - Creates a shaded relief map based
on current resolution settings and sun altitude and azimuth
values entered by the user.
(GRASS Shell Script)
SYNOPSIS
shade.rel.sh
shade.rel.sh help
shade.rel.sh [altitude=value]
[azimuth=value]
[elevation=name]
DESCRIPTION
shade.rel.sh is a Bourne shell (sh(1)) script that
creates a raster shaded relief map based on current
resolution settings and on sun altitude and azimuth values
entered by the user. The new shaded relief map is
named <elevation>.shade and stored in the user's current
mapset. The map is assigned a grey-scale color table.
In case, no parameter are provided on startup, this program is interactive;
the user enters the command:
-
shade.rel.sh
The program then prompts the user to enter values for:
- the altitude of the sun in degrees above the horizon
(a value between 0 and 90 degrees), and
- the azimuth of the sun in degrees to the east of north
(a value between -1 and 360 degrees).
- 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.
Specifically, shade.rel.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()) , \\
y=($elev[-1,-1] + 2*$elev[-1,0] + $elev[-1,1] \\
-$elev[1,-1] - 2*$elev[1,0] - $elev[1,1])/(8.*nsres()) , \\
slope=90.-atan(sqrt(x*x + y*y)), \\
a=round(atan(x,y)), \\
a=if(isnull(a),1,a), \\
aspect=if(x||y,if(a,a,360.)), \\
cang = sin($alt)*sin(slope) + cos($alt)*cos(slope) * cos($az-aspect), \\
if(cang < 0.,0.,100.*cang), \\
if(isnull(cang), null(), 100.*cang))
- 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.rel.sh then runs r.colors to assign a grey-scale color table to
the new shaded relief map <elevation>.shade, by executing the command:
-
r.colors shade color=grey
FILES
This program is simply a shell script. Users are encouraged to make their
own shell scripts using similar techniques. See
$GISBASE/scripts/shade.rel.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).
blend.sh
g.ask
g.region
r.colors
r.mapcalc
shade.clr.sh
AUTHOR
Jim Westervelt, U.S. Army Construction Engineering
Research Laboratory
Last changed: $Date$