Description Usage Arguments Details See Also Examples
The function provides the facility to average wind speed and direction data stored in two or more rasters ('RasterLayer' class). Of course, the input
rasters must have the same extent, resolution, and coordinate system.
1 | windAver(speed.data, dir.data)
|
speed.data: |
vector containing the name of the raster datasets ('RasterLayer' class) storing the wind speed data. |
dir.data: |
vector containing the name of the raster datasets ('RasterLayer' class) storing the wind direction data. |
The wind and direction rasters must be fed into the function as a vector storing the rasters' name.
The wind direction data are averaged by first computing the u and v components, then averaging them separately, and eventually converting them back to
degrees.
The u component is derived using the following formula:
-x * sin(2 * pi * y / 360)
where x and y are the wind speed and directions respectively;
the v component is derived using the following formula:
-x * cos(2 * pi * y / 360)
After being averaged, the averaged u and v components are converted back to degrees using the formula below:
(atan2(mean.u.comp, mean.v.comp) * 360/2/pi) + 180
The whole described procedure follows Grange, S. K. (2014). Technical note: Averaging wind speeds and directions.
Auckland. https://doi.org/10.13140/RG.2.1.3349.2006
The function produces:
-two plots representing the average wind speed and direction;
-two GTiff files (saved in the R working directory) for the average wind speed and direction.
The function also returns a list containing the following data:
-$wind.speed.avrg: wind speed data ('RasterLayer' class);
-$wind.dir.avrg: wind direction data ('RasterLayer' class).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # simulate toy data
set.seed(12345)
monthA_speed <- raster(xmn=0,xmx=4,ymn=0,ymx=4,res=1)
monthA_speed[] <- runif(16, 5,15)
plot(monthA_speed, main="month A speed")
text(monthA_speed)
monthB_speed <- raster(xmn=0,xmx=4,ymn=0,ymx=4,res=1)
monthB_speed[] <- runif(16, 10,20)
plot(monthB_speed, main="month B speed")
text(monthB_speed)
monthA_dir <- raster(xmn=0,xmx=4,ymn=0,ymx=4,res=1)
monthA_dir[] <- runif(16, 0,369)
plot(monthA_dir, main="month A dir")
text(monthA_dir)
monthB_dir <- raster(xmn=0,xmx=4,ymn=0,ymx=4,res=1)
monthB_dir[] <- runif(16, 0,369)
plot(monthB_dir, main="month B dir")
text(monthB_dir)
# calculate the average wind speed and direction for the two toy datasets
res <- windAver(speed.data= c(monthA_speed, monthB_speed), dir.data= c(monthA_dir, monthB_dir))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.