I have U and V wind component data and I would like to calculate wind direction from these values in R.
I would like to end up with wind direction data on a scale o
There are three problems with this:
atan2
, you must normalize them, but you don't do this by multiplying m/s by pi/180
(which you did to get u_rad
and v_rad
). You should make a column of absolute windspeed (sqrt(u_ms^2 + v_ms^2)
) and take atan2(u_ms/wind_abs, v_ms/wind_abs)
. (also note that atan2 takes y component first - make sure that's what you want)atan2
will give you an answer in the unit circle coordinates, which increase counterclockwise and have a zero on the x-axis. You want an answer in cardinal coordinates which increase clockwise and have a zero on the y-axis. To convert unit circle to cardinal coordinates, you must subtract the unit circle angle from 90.If you are given u_ms = = -3.711
and v_ms = -1.471
(on the unit circle it is blowing down and slightly to the left, so it is coming from the northeast), then:
wind_abs = sqrt(u_ms^2 + v_ms^2)
wind_dir_trig_to = atan2(u_ms/wind_abs, v_ms/wind_abs)
wind_dir_trig_to_degrees = wind_dir_trig_to * 180/pi ## -111.6 degrees
Then you must convert this wind vector to the meteorological convention of the direction the wind is coming from:
wind_dir_trig_from_degrees = wind_dir_trig_to_degrees + 180 ## 68.38 degrees
Then you must convert that angle from "trig" coordinates to cardinal coordinates:
wind_dir_cardinal = 90 - wind_dir_trig_from_degrees
[1] 21.62284 #From the northeast.