1

I have converted U and V component of wind to wind direction and magnitude. But didn't able to map this data using levelplot.

 library(raster)
 library(rgdal)
 library(rasterVis)
 library(lattice)
 library(grid)

Ucomplist <- list.files(path = "F:/ShareBoth/yearly_variable_data/rasters/Ucomp_annual/Ucomp_annual/", full.names = TRUE)
length(Ucomplist)
U <- brick(Ucomplist)

Vcomplist <- list.files(path = "F:/ShareBoth/yearly_variable_data/rasters/Vcomp_annual/Vcomp_annual/", full.names = TRUE)
length(Vcomplist)
V <- brick(Vcomplist)

wd <- (180/pi)*(atan2(U,V))
ws <- sqrt(U^2+V^2)

data link

https://drive.google.com/drive/folders/1PwABGUDBVUWi50Vfn9pmC-Dyjkpmtyny?usp=sharing

expected output:

wind direction in vector form with magnitude of wind speed

thanks in advance

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • Please make this question *reproducible*. This includes sample code (including listing non-base R packages), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Oct 31 '19 at 16:41
  • 1
    sorry I am new here, I have edited my question. please check it now – Muhammad Umar Oct 31 '19 at 17:56
  • That's a great start, thanks for improving the question a lot! I know that sometimes this kind of data can be difficult to share; links can (and often do) go stale, rendering this question unreproducible. If there are static datasets somewhere that also support this type of data (perhaps as part of an R package), that would be better sample data for questions on SO. Lastly, you show code for calculating, but don't show any warnings/errors or any attempt to plot. Where exactly are you having problems? – r2evans Oct 31 '19 at 18:13
  • thanks a lot, actually I want to map the wind speed and magnitude as given in sample maps above. But didn't find any clue. If you can help me in this regard, That'll be great. – Muhammad Umar Oct 31 '19 at 18:50
  • 1
    You should take a look at the `rasterVis::vectorplot` function. You will find examples [here](https://oscarperpinan.github.io/rastervis/#vectorplot) and [here](https://oscarperpinan.github.io/bookvis/spatial.html#vector). – Oscar Perpiñán Nov 04 '19 at 11:38

0 Answers0