How to map wind direction and speed (velocity plot) with R

Wave

Basically I have lists with 2 matrices (u and v) containing the windspeed in longitudal and latitudal direction (and vectors x and y containing the coordinates). I would like to make a map with arrows pointing in the resulting direction, of which the size is proportional to the wind speed. This question was asked before: http://www.mail-archive.com/[email protected]/msg18875.html. Uforunately, the link given in the answer is broken. I tried using the quiver function, but I don't get it working.

Here is how my data looks like:

x=seq(10,15,by=0.25)
y=seq(40,50,by=0.25)
u=matrix(runif(length(x)*length(y),-2,3),nrow=length(y),ncol=length(y))
v=matrix(runif(length(x)*length(y),-2,3),nrow=length(y),ncol=length(y))
wind=list(u,v)

For the quiver function:

library(pracma)
quiver(x=x, y=y, u=wind[[1]], v=wind[[2]])

Which gives twice:

Error: invalid graphics state

I assume that u and v are wrong and need to be coordinates as well, but I honestly don't understand the explanation given in the package discription (u, v : x,y-coordinates of start points).

I saw that more info is available for quiver in matlab or python, but I never worked with that, so any advice about doing this in R would be greatly appreciated.

Roland
x=seq(10,15,by=0.25)
y=seq(40,50,by=0.25)
u=matrix(runif(length(x)*length(y),-2,3),nrow=length(x),ncol=length(y))
v=matrix(runif(length(x)*length(y),-2,3),nrow=length(x),ncol=length(y))
#note that I corrected these

#melt for plotting
library(reshape2)
u <- melt(u,value.name = "u")
v <- melt(v,value.name = "v")
wind <- merge(u, v)
wind$x <- x[wind[,1]]
wind$y <- y[wind[,2]]


#plot
library(ggplot2)
library(grid)
scaler <- 1

p <- ggplot(wind, aes(x=x, y=y, xend=x+u*scaler, yend=y+v*scaler)) + geom_segment(arrow=arrow())
print(p)

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Seaborn: how to plot wind speed v direction on circular plot?

From Dev

Seaborn: how to plot wind speed v direction on circular plot?

From Dev

How to extract wind speed and wind direction from Windguru Spot service?

From Dev

Plotting wind speed and wind direction over time

From Dev

How to calculate wind direction from U and V wind components in R

From Dev

How to calculate wind direction from U and V wind components in R

From Dev

Wind direction and speed in a GPS App

From Dev

Calculating velocity from speed and direction

From Dev

How can I calculate wind direction average in R?

From Dev

Plot Wind Barb in R

From Dev

Sector wise mean wind speed and directions in R

From Dev

How to change speed/velocity of camera?

From Dev

How to change the axis label direction on a circular plot in R

From Dev

How to change the axis label direction on a circular plot in R

From Dev

Wind direction relative to travel

From Dev

wind direction on a compass wunderground

From Dev

Unity How to make GameObject Speed gain velocity

From Dev

Unity How to make GameObject Speed gain velocity

From Dev

ggplot2 time series plot with colour coded wind direction arrows

From Dev

How to plot arrows on map in R with ggmap

From Dev

How can I plot a continents map with R?

From Dev

How to manipulate xlim and ylim to plot a map in r

From Dev

How to plot a map from gadm in shiny r?

From Dev

Classify the wind direction in several classes

From Dev

How do I translate swipe speed and position to object velocity

From Dev

How do I translate swipe speed and position to object velocity

From Dev

How to keep velocity constant when object travels at peak speed

From Dev

Plotting geostrophic wind plot in matplotlib

From Dev

Plotting geostrophic wind plot in matplotlib

Related Related

  1. 1

    Seaborn: how to plot wind speed v direction on circular plot?

  2. 2

    Seaborn: how to plot wind speed v direction on circular plot?

  3. 3

    How to extract wind speed and wind direction from Windguru Spot service?

  4. 4

    Plotting wind speed and wind direction over time

  5. 5

    How to calculate wind direction from U and V wind components in R

  6. 6

    How to calculate wind direction from U and V wind components in R

  7. 7

    Wind direction and speed in a GPS App

  8. 8

    Calculating velocity from speed and direction

  9. 9

    How can I calculate wind direction average in R?

  10. 10

    Plot Wind Barb in R

  11. 11

    Sector wise mean wind speed and directions in R

  12. 12

    How to change speed/velocity of camera?

  13. 13

    How to change the axis label direction on a circular plot in R

  14. 14

    How to change the axis label direction on a circular plot in R

  15. 15

    Wind direction relative to travel

  16. 16

    wind direction on a compass wunderground

  17. 17

    Unity How to make GameObject Speed gain velocity

  18. 18

    Unity How to make GameObject Speed gain velocity

  19. 19

    ggplot2 time series plot with colour coded wind direction arrows

  20. 20

    How to plot arrows on map in R with ggmap

  21. 21

    How can I plot a continents map with R?

  22. 22

    How to manipulate xlim and ylim to plot a map in r

  23. 23

    How to plot a map from gadm in shiny r?

  24. 24

    Classify the wind direction in several classes

  25. 25

    How do I translate swipe speed and position to object velocity

  26. 26

    How do I translate swipe speed and position to object velocity

  27. 27

    How to keep velocity constant when object travels at peak speed

  28. 28

    Plotting geostrophic wind plot in matplotlib

  29. 29

    Plotting geostrophic wind plot in matplotlib

HotTag

Archive