Number of Storms by Basin

Row

Number of storms per basin by year

Storms Percentage per basin by year

Column

Storms path across various Basins

Year Wise Storm Data

Column

Storm Data for 2011

Column

Storm Data for 2012

Column

Storm Data for 2013

Monthly Storm Data Analysis

Column

Monthly Storms Plots - North America region

Monthly Storms Plots - Western Pacific Region

Monthly Storms Plots - Eastern Pacific region

Conclusion

Key Observations from the dashboard

  1. From the dashboard, we observed that number of storms per year in North America region decreased from 2010 to 2013 where as the number of storms in Western pacific and and eastern pacific region seem to increase.

  2. We have observed that the number of high wind speed storms, have increased in eastern pacific region compared to western pacific region in 2012 and 2013.

  3. From the monthly storm analysis, we observed that the months from July to October are the peak times of storms in western pacific region and north america regions whereas the months from December to March are the peak time of storm in eastern pacific region.

---
title: "Anly 512 : Data Visualization"
author: "Noble Verma"
date: "April 4, 2019"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code : embed 
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(flexdashboard)
library(knitr)
library(ggplot2)
library(ggthemes)
library(quantmod)
library(plyr)
library(DT)
library(quantmod)
library(plyr)
library(DT)
library(dygraphs)
library(xts)
library(zoo)
library(dplyr)
require(dplyr)
library(scales)
library(lubridate)
library(plotly)
library(rnoaa)
library(ggmap)
library(widgetframe)
library(rbokeh)
library(maps)
# options(noaakey = "EEfoMbwCSEbotNBNvGmJhOpyctlwKRUw")
# ncdc(datasetid='GHCND', stationid='GHCND:USW00014895', datatypeid='PRCP', startdate = '2010-05-01', enddate = '2010-10-31', limit=500)
STRM_2010 = storm_data(year='2010')
STRM_2011 = storm_data(year='2011')
STRM_2012 = storm_data(year='2012')
STRM_2013 = storm_data(year='2013')
STRM_2014 = storm_data(year='2014')
structure(STRM_2014)
STRM_2010_SUBSET = select(STRM_2010,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)
STRM_2011_SUBSET = select(STRM_2011,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)
STRM_2012_SUBSET = select(STRM_2012,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)
STRM_2013_SUBSET = select(STRM_2013,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)
STRM_2014_SUBSET = select(STRM_2014,serial_num,iso_time,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)
STORM_DATA_2010_2014=rbind(STRM_2010_SUBSET,STRM_2011_SUBSET,STRM_2012_SUBSET,STRM_2013_SUBSET,STRM_2014_SUBSET)

STORM_DATA_2010_2014$season = factor(STORM_DATA_2010_2014$season)
STORM_DATA_2010_2014$serial_num = factor(STORM_DATA_2010_2014$serial_num)
STORM_DATA_2010_2014$name = factor(STORM_DATA_2010_2014$name)


#To avoid downloading everytime, lets write this to a csv file
write.csv(STORM_DATA_2010_2014, file = 'STORM_DATA_2010_2014.csv')

STORM_DATA_2010_2014 <- read.csv(file = 'STORM_DATA_2010_2014.csv', header = TRUE)
STORM_DATA_2010_2014$season = factor(STORM_DATA_2010_2014$season)
STORM_DATA_2010_2014$serial_num = factor(STORM_DATA_2010_2014$serial_num)
STORM_DATA_2010_2014$name = factor(STORM_DATA_2010_2014$name)

STORM_DATA_2010_2014$iso_time = as.Date(STORM_DATA_2010_2014$iso_time, format = "%Y-%m-%d")
STORM_DATA_2010_2014$iso_months = months(STORM_DATA_2010_2014$iso_time)
STORM_DATA_2010_2014$iso_month = month(STORM_DATA_2010_2014$iso_time)
STORM_DATA_2010_2014$iso_month = factor(STORM_DATA_2010_2014$iso_month)

STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!="-999",]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!=-1,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!=0,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$pres.wmo.!=-1,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$pres.wmo.!=0,]
STORM_DATA_2010_2014$Basin_name = as.factor(paste(STORM_DATA_2010_2014$name, STORM_DATA_2010_2014$basin, 
    sep = "."))

summary(STORM_DATA_2010_2014)
```

Number of Storms by Basin
============================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------

### Storm Data & Unusual Weather Phenomenon   

This dashbord shows the occurence of stroms by number and area year over year. 
I have taken the data from the NCDC website and the data is downloaded using Rnoaa package.
We are given the storm data from 2010 to 2014 across the world. I have tried to visualise how occurence of storms have changed over time and area over a given time period. 

Questions from the dashboard:

First, I want to observe how number of storms in each basin vary.

Secondly, I want to know the usual wind speeds and pressure in different basins.

Thirdly, I also want to look at spatial plots of storms per year across different basins.

Fourthly, I want to see if there is any seasonal trend for the storms.

Row
-----------------------------------------------------------------------

### Number of storms per basin by year

```{r echo=FALSE}
STORM_DATA_2010_2014 %>%
  group_by(basin, season) %>% tally() %>%ggplot( aes(x=basin, y=n, fill=season)) + geom_bar(stat="identity",position="dodge")+ ggtitle("Number of storms per basin by year")+labs(x="Basin Name",y="Number of storms")
```



### Storms Percentage per basin by year

```{r echo=FALSE}
STORM_DATA_2010_2014 %>%
  group_by(basin, season) %>% tally() %>%ggplot( aes(x=basin, y=n, fill=season)) + geom_bar(stat="identity",position="fill")+ ggtitle("Storms Percentage per basin by year")+labs(x="Basin Name",y="Percentage")



```





Column {data-width=650}
-----------------------------------------------------------------------
### Storms path across various Basins

```{r echo=FALSE, fig.height=9, message=FALSE, warning=FALSE, paged.print=FALSE}

suppressWarnings(figure(width = 2000, height = 550, padding_factor = 0) %>%
  ly_map("world", col = "Brown") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping, data = STORM_DATA_2010_2014,color= wind.wmo.,glyph = season,size=3,hover = c(basin)))

# suppressWarnings(figure(width = 800, height = 450, padding_factor = 0) %>%
#   ly_map("world", col = "Brown") %>%
#   ly_points(longitude_for_mapping, latitude_for_mapping, data = STORM_DATA_2010_2014,color= basin,glyph = basin,hover = c(name,basin)))

```


Year Wise Storm Data
===========================================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------








### Spatial Visualization of Storms and wind speed

Here I plotted year wise storm data with wind speed. 

By Looking at spatial distribution by year gives us a clear picture of storms by year


Column
-----------------------------------------------------------------------
### Storm Data for 2011
```{r fig.height=3, fig.width=9, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}

 suppressWarnings(figure(width = 1400, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "Brown") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2011',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```



Column
-----------------------------------------------------------------------
### Storm Data for 2012
```{r fig.height=3, fig.width=9, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}


 suppressWarnings(figure(width = 1400, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "Brown") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2012',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```



Column
-----------------------------------------------------------------------
### Storm Data for 2013
```{r echo=FALSE, fig.height=3, fig.width=9, message=FALSE, warning=FALSE, Echo=FALSE, paged.print=FALSE}


 suppressWarnings(figure(width = 1400, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "Brown") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2013',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```


Monthly Storm Data Analysis
===========================================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------

### Seasonal Storm Analysis

The three regions with the higest number of storms are :
North America Region
Western Pacific region
Eastern Pacific region 

We plot the month wise paths of storms as this would give us an idea as in which season and which area is prone to storms. 

Column
--------------------------------------------------------------------
### Monthly Storms Plots - North America region
```{r fig.height=8, fig.width=7, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "Green4", colour = "Gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(-180, -20) + ylim(3, 
    80) +  labs(x = "", y = "", colour = "Wind \n(knots)") + scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)

```

### Monthly Storms Plots - Western Pacific Region
```{r fig.height=8, fig.width=7, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "green4", colour = "gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(80, 150) + ylim(0, 
    50) +  labs(x = "", y = "", colour = "Wind \n(knots)") +scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)

```

### Monthly Storms Plots - Eastern Pacific region
```{r fig.height=8, fig.width=7, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}


ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "green4", colour = "gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(40, 150) + ylim(-40, 
    5) +  labs(x = "", y = "", colour = "Wind \n(knots)") +scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)
 
 


```




Conclusion
==============================================================================================

Key Observations from the dashboard

1) From the dashboard, we observed that number of storms per year in North America region   decreased from 2010 to 2013 where as the number of storms in Western pacific and and eastern pacific region seem to increase. 

2) We have observed that the number of high wind speed storms, have increased in eastern pacific region compared to western pacific region in 2012 and 2013. 

3) From the monthly storm analysis, we observed that the months  from July to October are the peak times of storms in western pacific region and north america regions whereas the months from December to March are the peak time of storm in eastern pacific region.