Bench2Business

Watching Hurricane Sandy Graze by Toronto in R

Hurricane Sandy has already created some havoc in the US. Living in Toronto I am interested in seeing how this storm is going to affect us. The past few days have been particularly windy and rainy, but so far nothing has flown off my balcony just yet. I should probably take some things inside, in case we do get strong winds overnight, but it is looking like we will not be all that affected.

While tracking it on the news is nice, I was curious to see who in the R community has started looking at some public data. Note I said “who”, not “if”, because with something like this it is just a matter of who has an interesting approach. Bob Rudis showed  how he was tracking Sandy using R, and when he plotted his map it still looked like Sandy was heading straight north into Canada. I used his updated code from github, and made two small changes, to plot how Sandy is progressing, and how the projections are looking for Toronto.

By the time this storm hits the border its rage will have diminished into a “tropical depression”. The plot looks like it is passing east of Toronto heading towards Montreal. It will be interesting to keep rerunning this data later today and see how the projections continue to update.

Here is the code I changed to include Canada, and label some major Canadian cities:

# only want part of the map [I made the map bigger compared to the original code Bob posted].
xlim=c(-95,-60)
ylim=c(30,55)

# plot the map itself [changed to world map instead of state, and defined the region as Canada]
map("world", region="canada", interior = FALSE, xlim=xlim, ylim=ylim)
#map("state", interior=FALSE, xlim=xlim, ylim=ylim)
map("state", boundary = TRUE, col="gray", add = TRUE,xlim=xlim,ylim=ylim)

# added major cities in Canada and the USA with populations great than 1 and 2 million respectively
map.cities(country="Canada", minpop=1000000)
map.cities(country="USA", minpop=2000000)

Exit mobile version