New rWind release on CRAN! (v1.0.2)

July 4, 2018

(This article was first published on long time ago..., and kindly contributed to R-bloggers)

Hi there!
Just a few lines to inform you about the new release of rWind R package (v1.0.2). This version have several new features. Here you have an example of one of them, the function wind.dl_2 to download time series of wind data. In this example we create a bunch of PNG files to be converted later into a GIF of wind speed of east Asia region.

 # We will create a gif of wind speed for east Asia during the end of June (2018)  

# First, we should load the packages that we will use. Use install.packages() to
# download and install the new version of rWind (v1.0.2)




# Now, we use lubridate package to create a sequence of dates/times (each three
# hours)

dt <- seq(ymd_hms(paste(2018,6,25,00,00,00, sep="-")),
ymd_hms(paste(2018,7,4,21,00,00, sep="-")),by="3 hours")

# Now, we use the new function wind.dl_2 to download the whole time series of
# wind data. We use the "dt" object created with lubridate to provide the input
# to wind.dl_2. Since it's a large area and many days, it could take a while...

wind_series <- wind.dl_2(dt,90,150,5,40)

# Next, we can use wind2raster function from rWind package directly over the
# output from wind.dl_2, it has been adapted to work with this lists of wind
# data.

wind_series_layer <- wind2raster(wind_series)

# Finally, we will create a bunch of PNG files to be converted later in a GIF

for (i in 1:72) {
id <- sprintf("%03d", i)
png(paste("asia",id,".png", sep=""), width=1000, height=600, units="px",
image.plot(wind_series_layer[[i]]$wind.speed, col=bpy.colors(1000),
zlim=c(0,18), main =wind_series[[i]]$time[1])
lines(getMap(resolution = "low"), lwd=3)

To leave a comment for the author, please follow the link and comment on their blog: long time ago.... offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)