how to create vectorplot from velocity dataset?

2019-07-27 07:21发布

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)

Here the result

1条回答
闹够了就滚
2楼-- · 2019-07-27 07:45

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')
查看更多
登录 后发表回答