Skip to content
Prev 143355 / 398500 Next

How to plot wind direction and strength field

Does the following do what you want (or at least move in that
direction)?

u <- array(NA,c(5,8))
t <- seq(from=0.5, to=0.11,length=15)
t2 <- seq(from=(-0.7),to=(-0.1),length=25)
u[1:15] <- t
u[16:40] <- t2
v <- array(NA,c(5,8))
y <- seq(from=(-0.9), to=(-0.01),length=40) 
v[1:40] <- y

library(TeachingDemos)

library(maps)
map('state',col='grey')

lats <- seq( 27.5, 48.7, length=5 )
longs <- seq( -123, -73, length=8 )

x <- longs[ col(u) ]
y <- lats[ row(u) ]

speed <- sqrt( u*u+v*v )
dir <- atan2(v,u)

my.symbols(x,y,ms.arrows, angle=dir, r=speed, add=TRUE, length=.05)


Hope this helps,