[GRASS-dev] [GRASS GIS] #1057: r.slope.aspect: add -c option

#1057: r.slope.aspect: add -c option
-------------------------+--------------------------------------------------
Reporter: paoloC | Owner: grass-dev@lists.osgeo.org
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Is it possible to add a '-c' option to r.slope.aspect in order to get an
aspect raster map with compass notation (North=360, East=90, South=180,
West=270) ?

e.g.:

{{{
r.mapcalc "aspect_compass=if(isnull(aspect_from_east),null(), \
         if((aspect_from_east<90), 90-aspect_from_east, 360+90-
aspect_from_east))"
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1057&gt;
GRASS GIS <http://grass.osgeo.org>

#1057: r.slope.aspect: add -c option
--------------------------+-------------------------------------------------
  Reporter: paoloC | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: r.slope.aspect
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by martinl):

  * keywords: => r.slope.aspect
  * version: unspecified => svn-trunk

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1057#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1057: r.slope.aspect: add -c option
--------------------------+-------------------------------------------------
  Reporter: paoloC | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: r.slope.aspect
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by hamish):

it's pretty easy to do this by hand:
{{{
r.mapcalc "compass_aspect = 90 - theta_aspect"
}}}

and maybe a `if(aspect < 0) {aspect = aspect + 360 }` step after.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1057#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1057: r.slope.aspect: add -c option
--------------------------+-------------------------------------------------
  Reporter: paoloC | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: r.slope.aspect
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by glynn):

Replying to [ticket:1057 paoloC]:
> Is it possible to add a '-c' option to r.slope.aspect in order to get an
aspect raster map with compass notation (North=360, East=90, South=180,
West=270) ?
>
> e.g.:
>
{{{
r.mapcalc "aspect_compass=if(isnull(aspect_from_east),null(), \
         if((aspect_from_east<90), 90-aspect_from_east, 360+90-
aspect_from_east))"
}}}

Simpler version:
{{{
r.mapcalc "aspect_compass = (450 - aspect_from_east) % 360"
}}}

There's no need for an explicit null check, as almost any operation
involving null returns null.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1057#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1057: r.slope.aspect: add -c option
----------------------------+-----------------------------------------------
Reporter: paoloC | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.slope.aspect | Platform: Unspecified
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by hamish):

see code in addons/grass6/display/d.barb/main.c

{{{
     type_opt = G_define_option();
     type_opt->key = "aspect_type";
     type_opt->type = TYPE_STRING;
     type_opt->required = NO;
     type_opt->answer = "cartesian";
     type_opt->options = "cartesian,compass";
     type_opt->description = _("Direction map aspect type");
}}}

{{{
/* aspect flavours */
#define TYPE_GRASS 0
#define TYPE_COMPASS 1
...
     if (strcmp(type_opt->answer, "compass") == 0)
         aspect_type = TYPE_COMPASS;
     else
         aspect_type = TYPE_GRASS;
...
     angle = (aspect_type == TYPE_GRASS ? theta : 90 - theta);
}}}

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1057#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>