[GRASS-dev] [GRASS GIS] #2637: Get direction raster in clockwise degrees starting from the North
GRASS GIS
trac at osgeo.org
Thu Mar 26 02:48:41 PDT 2015
#2637: Get direction raster in clockwise degrees starting from the North
-------------------------+--------------------------------------------------
Reporter: cgravelm | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.1
Component: Raster | Version: 7.0.0
Keywords: | Platform: MacOSX
Cpu: Unspecified |
-------------------------+--------------------------------------------------
Comment(by neteler):
Replying to [comment:1 annakrat]:
> You can just use r.mapcalc "angle_cw = -angle_ccw + 450", this will give
you what you need. It outputs angles from 90 to 450, but that's typically
not a problem.
... or you solve it with an if() condition.
Shell script solution:
{{{
rotate_angle()
{
is_negative=`echo "$1" | awk '{printf "%d\n", $1 < 0. ? 1 : 0}'`
if [ $is_negative -eq 0 ] ; then
tmp=`echo "$1" | awk '{printf "%f\n", 360. - $1 + 90.}'`
tmp=`echo "$tmp" | awk '{printf "%f\n", $1 >= 360. ? $1 - 360. : $1}'`
echo "$tmp"
else
echo "NA"
fi
}
rotate_angle 270
#[1] 180
rotate_angle 180
#[1] 270
}}}
Likewise you could use r.mapcalc and its eval() function.
> I guess it could be implemented in r.slope.aspect.
Note the (old) patch:
raster/r.slope.aspect/r_sl_asp_northangle_diffs.tar.gz
Important: the output of r.slope.aspect can be used as input elsewhere,
hence a flag would increase the risk to mess up subsequent calculations.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2637#comment:3>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list