How does 'd.rgb' work?

Dave Gerdes dpgerdes at zorro.cecer.army.mil
Wed Mar 4 16:47:45 EST 1992


> From: "John E. Parks" <john at tang.uark.edu>
> Subject: Re: How does 'd.rgb' work?
> Date: Wed, 4 Mar 92 0:55:25 CST
> 
> |while I am on the subject, I have a new derivative of blend.sh called
> |intens.sh.   While blend.sh combines two colors into one, intens.sh 
> |is designed to work with a color file, and a grayscale file, using the
> |grayscale to vary the intensity of the colors.  This avoids the
> |'washed out' effect of you can get from blend.sh
> 
> I've heard that there is a script that will allow you to build 360
>   degree aspect maps instead of 24(15degree) maps. Is this true?
>   Sounds like it ought to be more than a script.
> 
>     __                   __ 
>    /  )      /          /  )     Research Specialist
>   /   / _   /_  _      /__/      Ctr for Advanced Spatial Technologies
>   (__/_(_)_/ /_/ )_   /   _      National Ctr for Resource Innovations
>     /                            12 Ozark Hall, Univ. of Arkansas
>    /                             Fayetteville, AR  72701
> John E. Parks                    phone: (501) 575-6159
> [john at tang.uark.edu] Internet    or: (501) 575-4575
> 

Well, I am sure there is more than one, but here is one that I have.  I 
hope it is acurate.  I threw it together from memory.  The map looks
reasonable at least.

---------------------------- Rip here ------------------------------------
:
# Usage: 0 elevation aspect
#   aspect is the output aspect file (0-360)
#
#
if test $# != 2
then
    echo "Usage: `basename $0` elevation aspect" >&2
    exit 1
fi
aspect=$2
elev=$1

r.mapcalc << EOF
$aspect = eval (\
root2 = 1.414213562, \
root3 = 1.732050808, \
A = ($elev[1,1]-$elev[1,-1]), \
B = ($elev[-1,-1]-$elev[1,-1]), \
U = (2*A), \
V = ((-2)*B), \
W = 2., \
mag = sqrt (1.*U*U+V*V+W*W), \
U = (U/mag), \
V = (V/mag), \
W = (W/mag), \
(((-U-V+W)/-root3) * 180 + 180 + 270) % 360)
EOF

# answer == -1 to 1
#  * 180 == -180 to 180
#  + 180 == 0 to 360
# + 270 % 360 ==  0 to 360, except that 0 is rotated to SE for aspect color file

r.colors $aspect co=aspect

exit 0
---------------------------- Rip here too --------------------------------


-- 



  Dave Gerdes
  US Army Construction Engineering Research Lab
  Spatial Analysis & Systems Team
  dpgerdes at cerl.cecer.army.mil
  (217) 352-6511 x591



More information about the grass-user mailing list