[R] convert wind direction from degrees to basic compass dir

(Ted Harding) ted.harding at wlandres.net
Sat Oct 23 23:57:05 CEST 2010


On 23-Oct-10 21:15:37, will phillips wrote:
> Hello Josh,
> Thank you for the tip on the cut function. I'm new to R and have
> not come across this one yet. I'll give it a go.
> 
> Regarding the rationale for segmenting the wind direction, I have
> not come across any theory to drive this. My motivation is model
> fit. This wind direction variable really isn't contributing anything
> to the model as a continuous variable but before casting it aside,
> I thought transforming it into a categorical variable might show
> something useful. The 8 basic map directions seem natural
> 
> In this same data set I had a variable "days since start" and it
> was continuous and not significant but when factored in as day of
> the week, I'm seeing significance on every day.
> 
> Will
> --

It would be useful for us to have more insight into the variable
being modelled ("outcome variable" if you like).

Wind direction is a "circular variable" -- whether expressed
in degrees or in compass sectors (N, NE, E, SE, S, SW, W, NW)
it will wrap round to the beginning when it gets to the end
(359 --> 0, NW --> N). Rather like days of the week, in fact ...

So you could be dealing with something best handled in terms
of circular statistics, for whach there are various packages
in R, such as (using my local CRAN mirror):

CircStats: http://finzi.psych.upenn.edu/R/library/CircStats

CircSpatial:
http://www.stats.bris.ac.uk/R/web/packages/CircSpatial/index.html

Circular:
http://www.stats.bris.ac.uk/R/web/packages/circular/index.html

The basic problem with an "ordinary" model incorporating a
circular variable is that the natural ordering of the values
(whether expressed in numerical degrees or as an ordered
"compass points" factor) breaks down: you could have things
like 45 < 180 < 275 < 350 < 10 or SE < W < N < E.

In particular, the effect of wind at 359 degrees is likely
to be similar to the effect of wind at 1 degree, likewise
wind in the sector N to be similar to wind in sector NE.
Yet this relationship of neighbourhood persists around the
whole circle of the compass, so will not be correctly
represented by either a numeric nor an ordered factor
unless the topology of the circle is taken into account.

So the circularity needs to be incorporated into the model,
somehow. How best to do it will depend on what is being
modelled, and on how you expect it to be related to wind
direction.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Oct-10                                       Time: 22:56:52
------------------------------ XFMail ------------------------------



More information about the R-help mailing list