使用lon,lat坐标在地图中绘制windrose

时间:2018-05-29 21:44:01

标签: r gis

我有两个矩阵,其中包含海洋中地转流的u和v分量。矩阵是240x242,行是经度点和列纬度点。我想使用lon,lat坐标在等距网格(例如,每5个网格点)之后在地图内绘制windrose。我试过windrose(圆形)和windRose(openair包),没有任何成功。这可能吗?我检查了这个论坛,找不到我的问题的答案。 非常感谢。

#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? ####

0 个答案:

没有答案