how to create vectorplot from velocity dataset?

♀尐吖头ヾ 提交于 2019-12-13 01:59:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!