On 22/01/13 17:45, Margherita Di Leo wrote:
Hi,
I figured out that sometimes it would be useful to have a script for
converting a direction map which uses the convention degrees clockwise
from North, into the GRASS convention, which is as you well know degrees
from East counterclockwise [1]. The aim is to deal with wind direction
maps for example, which often use the above mentioned convention [2],
but also some other software.
I wrote a short tentative of such conversion tool in the form of a grass
addon for myself, enclosed. I would like to know:
1) if would be of interest for anyone here, i.e. worth to be published
in the addon repo;
+1, once it is correct.
2) if you have any idea how to make the several time nested r.mapcalc
expression less awful :-)
For me it looks ok as is (with below corrections). Or maybe you could
simply use r.recode with rules such as:
0:89.999:90:0.999
90:360:360:90
(probably need a better way to treat the special role of '0' in GRASS).
Give it a try.
If we call WIND the direction map which uses the convention degrees
clockwise from North, and GRASS the output map, the rule that I applied is:
IF 0 <= WIND < 270 ; GRASS = 270 - WIND
IF WIND = 270 ; GRASS = 360
IF 270 < WIND < 360 ; GRASS 630 - 0
IF WIND = null ; GRASS = 0
NULL otherwise (this latter I have added to check if there is any error.
This is not correct.
WIND = 0 means North. North in GRASS convention is 90, but 270 - 0 <> 90.
Same with WIND = 270 which is West IIUC, so this should be 180 in GRASS
convention, not 360.
This should work I think:
IF 0 <= WIND < 90 ; GRASS = 90-WIND
IF 90 <= WIND <= 360 ; GRASS = 450 - WIND
Moritz
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev