Opened 14 years ago
Closed 6 years ago
#1057 closed enhancement (fixed)
r.slope.aspect: add -c option
| Reported by: | paoloC | Owned by: | |
|---|---|---|---|
| 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 , 14 years ago
| Keywords: | r.slope.aspect added |
|---|---|
| Version: | unspecified → svn-trunk |
comment:2 by , 14 years ago
comment:3 by , 14 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 , 12 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 , 8 years ago
| Milestone: | 7.0.0 → 7.0.5 |
|---|
comment:6 by , 8 years ago
| Keywords: | compass directions angles added |
|---|---|
| Milestone: | 7.0.5 → 7.3.0 |
| Priority: | normal → minor |
comment:9 by , 6 years ago
| Milestone: | 7.4.1 → 7.6.0 |
|---|
Implemented as new -n flag in r72229. The ticket can be closed when 7.6 is out.
comment:10 by , 6 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Closing as added to https://trac.osgeo.org/grass/wiki/Release/7.6.0-News

it's pretty easy to do this by hand:
and maybe a
if(aspect < 0) {aspect = aspect + 360 }step after.Hamish