[GRASS-dev] [GRASS GIS] #2637: Get direction raster in clockwise degrees starting from the North
GRASS GIS
trac at osgeo.org
Thu Mar 26 12:47:06 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 cmbarton):
Replying to [comment:3 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.
I don't see how a flag would mess up other calculations. Different other
routines use different ways of representing aspect. So you need to know
what is needed and select that even now. There are also potential uses
that could benefit by having aspect in the cardinal directions. It is a
pain to always have to convert the output to make it readable for humans
in normal ways too. A simple flag seems like a nice improvement here.
Michael
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2637#comment:5>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list