UPDATE:
- Significantly updated code on github
- Well, a couple folks asked how to make it more “centered” on the hurricane and stop the labels from chopping off, so I modified the previous code a bit to show how to do that.
As indicated in the code comments, Google took down the cone KML files. I’ll be changing the code to use the NHC archived cone files later tonight
While this will pale in comparison to the #spiffy
Sandy graphics on Weather Underground and other sites (including Google’s “Crisis Center” maps), I thought it might be interesting to show folks how they can keep an eye on “Sandy” using R.
library(maps) trim.trailing <- function (x) sub("\\s+$", "", x) wx = read.table(file="http://weather.unisys.com/hurricane/atlantic/2012/SANDY/track.dat", skip=3,fill=TRUE) wx$V7 = trim.trailing(paste(wx$V7,wx$V8," ")) wx$V8 = NULL colnames(wx) = c("Advisory","Latitude","Longitude","Time","WindSpeed","Pressure","Status") wx$Advisory = unlist(strsplit(toString(wx$Advisory),", ")) wx$a = "" wx$a[grep("\\+",wx$Advisory)] = wx$Advisory[grep("\\+",wx$Advisory)] wx$Status = trim.trailing(paste(wx$Status,wx$a," ")) wx$color = "red" wx$color[grep("\\+",wx$Advisory)] = "orange" xlim=c(-90,-60) map("state", interior = FALSE, xlim=xlim) map("state", boundary = FALSE, col="gray", add = TRUE,xlim=xlim) points(x=wx$Longitude,y=wx$Latitude,col=wx$color,pch=17,cex=0.75) text(x=wx$Longitude,y=wx$Latitude,col='blue',labels=wx$Status,adj=c(-.15),cex=0.33) box()
This short script reads in data from the Unisys Hurricane Weather Center and plots colored symbols on a US map with the forecast projections. I may be extending this, but it’s a good starting point for anyone who wants to play with mapping relatively live data from the internet (or learn some more R).