I have two matrix with the u and v components of geostrophic current in the ocean. The matrix are 240x242, rows being longitude points and columns latitude points. I would like to plot a windrose inside a map following an equidistant grid (for example, each 5 grid points)using the lon,lat coordinates. I have tried with windrose (circular) and windRose (openair package), without any success. Is this possible? I checked this forum and couldn't find an answer for my issue. Thanks a lot.
#R version: 3.4.4
library(maps) # maps ver. 3.3.0
library(openair) # openair ver. 2.4-2
library(circular) # circular ver. 0.4-93
#Geographic coordinates
lats <- seq(18, 30, 3)
lons <- seq(-98, -86, 3)
lonlats <- expand.grid(lons, lats)
#simulate some current (or wind) data: dir is direction, spd is speed or
#magnitude.data are arrays of dimension longitudexlatitudex50, where the
#third dimension contains a timeseries of each (lon,lat) pair.
arr.dir <- array(sample(1:360, 1250, replace=T), dim = c(5,5,50))
arr.spd <- array(sample(0:140, 1250, replace=T), dim = c(5,5,50))
#visualize grid in a map
plot(lonlats$Var1, lonlats$Var2, xlab="Longitude", ylab="Latitude",
asp=1, pch=19)
map(database = "world", add=T, fill=T, col="gray"); box()
#windroses for the time series at (-86,30), at the right upper corner of
#the map.
#with circular
rose1 <- data.frame(dir=circular(arr.dir[5,5,], units="degrees",
template="geographics"), mag=arr.spd[5,5,])
windrose(rose1)
#with openair
windRose(mydata = data.frame(ws=arr.spd[5,5,], wd=arr.dir[5,5,]),
paddle=F)
#### question: how do I plot one of the roses (preferablly with openair)
#in the map, at the corresponding coordinates? ####