问题
Related to my previous question about calculate atan2 from two raster object in R?. It's possible to create a vector plot where the speed (slope) and direction (aspect) is displayed with a set of arrows (e.g. quiver in Matlab) based on this equation:
for speed : ws <- sqrt(u^2+v^2)
for direction : wd <- (180/pi)*(atan2(u,v))
my dataset sample can be downloaded here
u <- raster(flname, varname = 'U')
v <- raster(flname, varname = 'V')
uv <- stack(u,v)
I used rasterVis package to figure the plot, but the result is not fit.
library(rasterVis)
vectorplot(uv)
回答1:
From the help page of vectorplot
:
If ‘isField='dXY'’ ‘object’ must be a Raster* with two layers representing the horizontal and the vertical components, respectively.
Thus, the solution is:
vectorplot(uv, isField = 'dXY')
来源:https://stackoverflow.com/questions/36174721/how-to-create-vectorplot-from-velocity-dataset