Synopsis

During this project, the storm database from the National Oceanic and Atmospheric Administration (NOAA) in the United States is analyzed. For any kind of catastrophe (such as a flood, typhoon, tornado, hailstorm, hurricane, etc.), we calculate the number of fatalities, injuries, property damage, and crop damage. Our objective is to ascertain which incident has the most economic ramifications and which is most detrimental to the health of the US populace. According to our analysis of fatalities and injuries, tornadoes are the most dangerous natural disaster for US health (population). However, we determine that Flood has the biggest economic impact on the US based on Property and Cost damage.

Introduction

Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern.

This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.

Data

The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. You can download the file from the course web site:

Storm Data

There is also some documentation of the database available. Here you will find how some of the variables are constructed/defined.

National Weather Service Storm Data Documentation

National Climatic Data Center Storm Events FAQ

The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.

Assignment

The basic goal of this assignment is to explore the NOAA Storm Database and answer some basic questions about severe weather events. You must use the database to answer the questions below and show the code for your entire analysis. Your analysis can consist of tables, figures, or other summaries. You may use any R package you want to support your analysis.

Questions

Your data analysis must address the following questions:

  1. Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

  2. Across the United States, which types of events have the greatest economic consequences?

Consider writing your report as if it were to be read by a government or municipal manager who might be responsible for preparing for severe weather events and will need to prioritize resources for different types of events. However, there is no need to make any specific recommendations in your report.

R Packages required for Data Analysis

library(data.table)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
## 
##     between, first, last
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(tidyr)

Loading the Data File

data <- read.csv("repdata-data-StormData.csv.bz2", header = TRUE, sep=",")

Columns Name Checking

colnames(data)
##  [1] "STATE__"    "BGN_DATE"   "BGN_TIME"   "TIME_ZONE"  "COUNTY"    
##  [6] "COUNTYNAME" "STATE"      "EVTYPE"     "BGN_RANGE"  "BGN_AZI"   
## [11] "BGN_LOCATI" "END_DATE"   "END_TIME"   "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE"  "END_AZI"    "END_LOCATI" "LENGTH"     "WIDTH"     
## [21] "F"          "MAG"        "FATALITIES" "INJURIES"   "PROPDMG"   
## [26] "PROPDMGEXP" "CROPDMG"    "CROPDMGEXP" "WFO"        "STATEOFFIC"
## [31] "ZONENAMES"  "LATITUDE"   "LONGITUDE"  "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS"    "REFNUM"

Data Processing

Selecting the columns only required for analysis.

selection <- c('EVTYPE', 'FATALITIES', 'INJURIES', 'PROPDMG', 'PROPDMGEXP', 'CROPDMG', 'CROPDMGEXP')
data <- data[, selection]
summary(data)
##     EVTYPE            FATALITIES          INJURIES            PROPDMG       
##  Length:902297      Min.   :  0.0000   Min.   :   0.0000   Min.   :   0.00  
##  Class :character   1st Qu.:  0.0000   1st Qu.:   0.0000   1st Qu.:   0.00  
##  Mode  :character   Median :  0.0000   Median :   0.0000   Median :   0.00  
##                     Mean   :  0.0168   Mean   :   0.1557   Mean   :  12.06  
##                     3rd Qu.:  0.0000   3rd Qu.:   0.0000   3rd Qu.:   0.50  
##                     Max.   :583.0000   Max.   :1700.0000   Max.   :5000.00  
##   PROPDMGEXP           CROPDMG         CROPDMGEXP       
##  Length:902297      Min.   :  0.000   Length:902297     
##  Class :character   1st Qu.:  0.000   Class :character  
##  Mode  :character   Median :  0.000   Mode  :character  
##                     Mean   :  1.527                     
##                     3rd Qu.:  0.000                     
##                     Max.   :990.000

Selecting the data only related to injuries, fatalities, property damage and crop damage

data <- as.data.table(data)
data <- data[(EVTYPE != "?" & (INJURIES > 0 | FATALITIES > 0 | PROPDMG > 0 | CROPDMG > 0)), 
             c("EVTYPE", "FATALITIES", "INJURIES", "PROPDMG", "PROPDMGEXP", "CROPDMG", "CROPDMGEXP")]

Converting the columns CROPDMG and PROPDMG to values

cols <- c("PROPDMGEXP", "CROPDMGEXP")
data[,  (cols) := c(lapply(.SD, toupper)), .SDcols = cols]

PROPDMGKey <-  c("\"\"" = 10^0, 
                 "-" = 10^0, "+" = 10^0, "0" = 10^0, "1" = 10^1, "2" = 10^2, "3" = 10^3,
                 "4" = 10^4, "5" = 10^5, "6" = 10^6, "7" = 10^7, "8" = 10^8, "9" = 10^9, 
                 "H" = 10^2, "K" = 10^3, "M" = 10^6, "B" = 10^9)
CROPDMGKey <-  c("\"\"" = 10^0, "?" = 10^0, "0" = 10^0, "K" = 10^3, "M" = 10^6, "B" = 10^9)

data[, PROPDMGEXP := PROPDMGKey[as.character(data[,PROPDMGEXP])]]
data[is.na(PROPDMGEXP), PROPDMGEXP := 10^0 ]

data[, CROPDMGEXP := CROPDMGKey[as.character(data[,CROPDMGEXP])] ]
data[is.na(CROPDMGEXP), CROPDMGEXP := 10^0 ]

Adding two new columns to the dataframe Property Cost and Crop Cost

data <- data[, .(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, PROPCOST = PROPDMG * PROPDMGEXP, CROPDMG, CROPDMGEXP, CROPCOST = CROPDMG * CROPDMGEXP)]

Analysis

Estimating the total number of Fatalities and Injuries

Health_Impact <- data[, .(FATALITIES = sum(FATALITIES), INJURIES = sum(INJURIES), TOTAL_HEALTH_IMPACTS = sum(FATALITIES) + sum(INJURIES)), by = .(EVTYPE)]

Health_Impact <- Health_Impact[order(-TOTAL_HEALTH_IMPACTS), ]

Health_Impact <- Health_Impact[1:10, ]

head(Health_Impact, 10)
##                EVTYPE FATALITIES INJURIES TOTAL_HEALTH_IMPACTS
##  1:           TORNADO       5633    91346                96979
##  2:    EXCESSIVE HEAT       1903     6525                 8428
##  3:         TSTM WIND        504     6957                 7461
##  4:             FLOOD        470     6789                 7259
##  5:         LIGHTNING        816     5230                 6046
##  6:              HEAT        937     2100                 3037
##  7:       FLASH FLOOD        978     1777                 2755
##  8:         ICE STORM         89     1975                 2064
##  9: THUNDERSTORM WIND        133     1488                 1621
## 10:      WINTER STORM        206     1321                 1527

Estimating the total number of Property Cost and Crop Cost

Eco_Impact <- data[, .(PROPCOST = sum(PROPCOST), CROPCOST = sum(CROPCOST), TOTAL_ECO_IMPACTS = sum(PROPCOST) + sum(CROPCOST)), by = .(EVTYPE)]

Eco_Impact <- Eco_Impact[order(-TOTAL_ECO_IMPACTS), ]

Eco_Impact <- Eco_Impact[1:10, ]

head(Eco_Impact, 10)
##                EVTYPE     PROPCOST    CROPCOST TOTAL_ECO_IMPACTS
##  1:             FLOOD 144657709807  5661968450      150319678257
##  2: HURRICANE/TYPHOON  69305840000  2607872800       71913712800
##  3:           TORNADO  56947380677   414953270       57362333947
##  4:       STORM SURGE  43323536000        5000       43323541000
##  5:              HAIL  15735267513  3025954473       18761221986
##  6:       FLASH FLOOD  16822673979  1421317100       18243991079
##  7:           DROUGHT   1046106000 13972566000       15018672000
##  8:         HURRICANE  11868319010  2741910000       14610229010
##  9:       RIVER FLOOD   5118945500  5029459000       10148404500
## 10:         ICE STORM   3944927860  5022113500        8967041360

Results

Answer to Question 1

Health_Consequences <- melt(Health_Impact, id.vars = "EVTYPE", variable.name = "Fatalities_or_Injuries")

ggplot(Health_Consequences, aes(x = reorder(EVTYPE, -value), y = value)) + 
  geom_bar(stat = "identity", aes(fill = Fatalities_or_Injuries), position = "dodge") + 
  ylab("Total Injuries/Fatalities") + 
  xlab("Event Type") + 
  theme(axis.text.x = element_text(angle=45, hjust=1)) + 
  ggtitle("Top 10 US Weather Events that are Most Harmful to Population") + 
  theme(plot.title = element_text(hjust = 0.5))

Answer to question 2

Eco_Consequences <- melt(Eco_Impact, id.vars = "EVTYPE", variable.name = "Damage_Type")

ggplot(Eco_Consequences, aes(x = reorder(EVTYPE, -value), y = value/1e9)) + 
  geom_bar(stat = "identity", aes(fill = Damage_Type), position = "dodge") + 
  ylab("Cost/Damage (in billion USD)") + 
  xlab("Event Type") + 
  theme(axis.text.x = element_text(angle=45, hjust=1)) + 
  ggtitle("Top 10 US Weather Events that have the Greatest Economic consequences") + 
  theme(plot.title = element_text(hjust = 0.5))

Conclusion

The analysis suggests that stronger infrastructure or early warning systems should be built in order to mitigate the effects of tornadoes on population health and safety. Regarding hurricane and typhoon preparedness, increased funding should be allocated to innovative projects that create stronger infrastructure and systems to protect these assets and crops from destruction.