Opened 9 years ago

Closed 14 months 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 Changed 9 years ago by martinl

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

comment:2 Changed 9 years ago 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

comment:3 in reply to:  description Changed 9 years ago by glynn

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 Changed 7 years ago 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

comment:5 Changed 3 years ago by martinl

Milestone: 7.0.07.0.5

comment:6 Changed 3 years ago by wenzeslaus

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

comment:7 Changed 3 years ago by martinl

Milestone: 7.3.07.4.0

Milestone renamed

comment:8 Changed 21 months ago by neteler

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:9 Changed 18 months ago by mmetz

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 Changed 14 months ago by neteler

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