Synopsis

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.

The following reports are representing the study done on human and property damages and results are showing the most dangerous wheater events.

Datasource

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:

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 the following basic questions about severe weather events.

Data Processing

Data loading

The dataset StormData.csv is file contained in the archive mentioned in the Storm Data download link. It will be loaded into R workspace.

library(ggplot2)

storm_data <- read.csv("StormData.csv")
str(storm_data)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
##  $ BGN_TIME  : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
##  $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
##  $ STATE     : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : Factor w/ 35 levels "","  N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_LOCATI: Factor w/ 54429 levels "","- 1 N Albion",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_DATE  : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_TIME  : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_LOCATI: Factor w/ 34506 levels "","- .5 NNW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ WFO       : Factor w/ 542 levels ""," CI","$AC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ ZONENAMES : Factor w/ 25112 levels "","                                                                                                                               "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : Factor w/ 436774 levels "","-2 at Deer Park\n",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

Property damage values transform and calculation

Property damage exponents are transformed in numerical values for the property exponent data. Each invalid value was signed with a 0 value. The calculation has been executed by multiplying the property damage and property exponent.

# Getting unique values for property damage exponent and levels
unique(storm_data$PROPDMGEXP)
##  [1] K M   B m + 0 5 6 ? 4 2 3 h 7 H - 1 8
## Levels:  - ? + 0 1 2 3 4 5 6 7 8 B h H K m M
# Transform values for the property exponent data 
storm_data$PROPEXP[storm_data$PROPDMGEXP == "K"] <- 1000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "M"] <- 1000000
storm_data$PROPEXP[storm_data$PROPDMGEXP == ""] <- 1
storm_data$PROPEXP[storm_data$PROPDMGEXP == "B"] <- 1000000000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "m"] <- 1000000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "0"] <- 1
storm_data$PROPEXP[storm_data$PROPDMGEXP == "5"] <- 100000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "6"] <- 1000000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "4"] <- 10000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "2"] <- 100
storm_data$PROPEXP[storm_data$PROPDMGEXP == "3"] <- 1000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "h"] <- 100
storm_data$PROPEXP[storm_data$PROPDMGEXP == "7"] <- 10000000
storm_data$PROPEXP[storm_data$PROPDMGEXP == "H"] <- 100
storm_data$PROPEXP[storm_data$PROPDMGEXP == "1"] <- 10
storm_data$PROPEXP[storm_data$PROPDMGEXP == "8"] <- 100000000

# All not valid values set to zero
storm_data$PROPEXP[storm_data$PROPDMGEXP == "+"] <- 0
storm_data$PROPEXP[storm_data$PROPDMGEXP == "-"] <- 0
storm_data$PROPEXP[storm_data$PROPDMGEXP == "?"] <- 0

# Calculating the property damage value
storm_data$PROPDMGVAL <- storm_data$PROPDMG * storm_data$PROPEXP

Crop damage values transform and calculation

Crop damage exponents are transformed in numerical values for the property exponent data. Each invalid value was signed with a 0 value. The calculation has been executed by multiplying the crop damage and crop exponent.

# Getting unique values for crop damage exponent and levels
unique(storm_data$CROPDMGEXP)
## [1]   M K m B ? 0 k 2
## Levels:  ? 0 2 B k K m M
# Transform values for the crop exponent data 
storm_data$CROPEXP[storm_data$CROPDMGEXP == "M"] <- 1000000
storm_data$CROPEXP[storm_data$CROPDMGEXP == "K"] <- 1000
storm_data$CROPEXP[storm_data$CROPDMGEXP == "m"] <- 1000000
storm_data$CROPEXP[storm_data$CROPDMGEXP == "B"] <- 1000000000
storm_data$CROPEXP[storm_data$CROPDMGEXP == "0"] <- 1
storm_data$CROPEXP[storm_data$CROPDMGEXP == "k"] <- 1000
storm_data$CROPEXP[storm_data$CROPDMGEXP == "2"] <- 100
storm_data$CROPEXP[storm_data$CROPDMGEXP == ""] <- 1

# All not valid values set to zero
storm_data$CROPEXP[storm_data$CROPDMGEXP == "?"] <- 0

# Calculating the crop damage value
storm_data$CROPDMGVAL <- storm_data$CROPDMG * storm_data$CROPEXP

Total calculation

Total for incident by event type

  • The most harmful incidents for the populatio health are Fatalities and Injuries. This means that only those kind of incidents were selected.

  • Same reasoning was applied to the economy topic. The most harmful events for the economy are Property damage and Crop damage. Only those events were selected.

# Totals calculation
fatalities <- aggregate(FATALITIES ~ EVTYPE, storm_data, FUN = sum)
injuries <- aggregate(INJURIES ~ EVTYPE, storm_data, FUN = sum)
properties_damage <- aggregate(PROPDMGVAL ~ EVTYPE, storm_data, FUN = sum)
crop_damage <- aggregate(CROPDMGVAL ~ EVTYPE, storm_data, FUN = sum)

Sorting the datasets

Totals were sorted from the most harmful by decreasing.

# Sorting data frames
fatalities <- fatalities[order(-fatalities$FATALITIES), ]
injuries <- injuries[order(-injuries$INJURIES), ]
properties_damage <- properties_damage[order(-properties_damage$PROPDMGVAL), ]
crop_damage <- crop_damage[order(-crop_damage$CROPDMGVAL), ]

Results

Plotting events with highest fatalities and injuries

The following plots shows the top 20 events.

# Selecting top events
fatalities_data_plot <- head(fatalities, 20)
injuries_data_plot <- head(injuries, 20)

# Fatalities plot
ggplot(data = fatalities_data_plot, aes(x = reorder(factor(EVTYPE), -FATALITIES), y = FATALITIES)) + 
    geom_bar(stat = "identity") + 
    labs(title = "Events with high Fatality", x = "Event Types", y = "Fatality") + 
    theme(axis.text.x = element_text(angle = 45, hjust = 1))

# Injuries plot
ggplot(data = injuries_data_plot, aes(x = reorder(factor(EVTYPE), -INJURIES), y = INJURIES)) + 
    geom_bar(stat = "identity") + 
    labs(title = "Events with high Injury", x = "Event Types", y = "Injury") + 
    theme(axis.text.x = element_text(angle = 45, hjust = 1))

Plotting events with highest Property damage and crop damage

The following plots shows the top 20 events.

# Selecting top events
properties_damage_data_plot <- head(properties_damage, 20)
crop_damage_data_plot <- head(crop_damage, 20)

# Properties damage plot
ggplot(data = properties_damage_data_plot, aes(x = reorder(factor(EVTYPE), -PROPDMGVAL), y = PROPDMGVAL)) + 
    geom_bar(stat = "identity") + 
    labs(title = "Events with high Property damage", x = "Event Types", y = "Property damage") + 
    theme(axis.text.x = element_text(angle = 45, hjust = 1))

# Crop damage plot
ggplot(data = crop_damage_data_plot, aes(x = reorder(factor(EVTYPE), -CROPDMGVAL), y = CROPDMGVAL)) + 
    geom_bar(stat = "identity") + 
    labs(title = "Events with high Crop damage", x = "Event Types", y = "Crop damage") + 
    theme(axis.text.x = element_text(angle = 45, hjust = 1))

Conclusions

The top 3 events for Fatalities and Injuries are

  • Fatalities
    1. Tornado
    2. Excessive Heat
    3. Flash Flood
  • Injuries
    1. Tornado
    2. TSTM wind
    3. Flood

The top 3 events for Property damage and Crop damage are

  • Property damage
    1. Flood
    2. Hurricane/Typhoon
    3. Tornado
  • Crop damage
    1. Drought
    2. Flood
    3. River Flood