[GRASS-dev] [GRASS GIS] #2637: Get direction raster in clockwise degrees starting from the North

GRASS GIS trac at osgeo.org
Fri Mar 27 09:03:04 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 glynn):

 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, if you want to limit the range to 0..360, use:

 r.mapcalc "angle_cw = (450 - angle_ccw) % 360"

 Similarly, if you want -180..180 (again, clockwise from North):

 r.mapcalc "angle_cw = (630 - angle_ccw) % 360 - 180"

 Similar formulae can be used for any other convention. The main caveat is
 that the left-hand operand to the % (modulo) operator needs to be non-
 negative in order to obtain a non-negative result.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2637#comment:6>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list