Opened 12 years ago

Closed 4 years ago

#1057 closed enhancement (fixed)

r.slope.aspect: add -c option

Reported by: paoloC Owned by: grass-dev@…
Priority: minor Milestone: 7.6.0
Component: Raster Version: svn-trunk
Keywords: r.slope.aspect, compass, directions, angles Cc:
CPU: Unspecified Platform: Unspecified

Description

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))"

Change History (10)

comment:1 by martinl, 12 years ago

Keywords: r.slope.aspect added
Version: unspecifiedsvn-trunk

comment:2 by hamish, 12 years ago

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

in reply to:  description comment:3 by glynn, 12 years ago

Replying to 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.

comment:4 by hamish, 10 years ago

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

comment:5 by martinl, 6 years ago

Milestone: 7.0.07.0.5

comment:6 by wenzeslaus, 6 years ago

Keywords: compass directions angles added
Milestone: 7.0.57.3.0
Priority: normalminor

comment:7 by martinl, 6 years ago

Milestone: 7.3.07.4.0

Milestone renamed

comment:8 by neteler, 4 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:9 by mmetz, 4 years ago

Milestone: 7.4.17.6.0

Implemented as new -n flag in r72229. The ticket can be closed when 7.6 is out.

comment:10 by neteler, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.