Introduction

This map show the 3 main storm event in 2018 in USA. The radius of the circle means the total cost of the property and the crop.

Loading Labrary

suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(leaflet))

Loading abd Cleaning the data

dat = read.csv("StormEvents_2018.csv")
dat = dat[,c("Event_Type","Begin_Lat","Begin_Lon","Property_Cost","Crop_Cost")]
dat = dat[dat$Event_Type %in% c("Flood","Thunderstorm Wind","Marine Thunderstorm Wind"), ]
dat= na.omit(dat)
dat$Total_cost = dat$Property_Cost+dat$Crop_Cost
dat_f = dat[,-c(4,5)]
dat_f$Color = 0

for(i in 1:17051){
        if(dat_f$Event_Type[i] == "Flood"){
                dat_f$Color[i] = "blue"
}
         else if(dat_f$Event_Type[i] == "Thunderstorm Wind"){
                dat_f$Color[i] = "orange"
         }
       
        else{
                dat_f$Color[i] = "yellow"
        }
}

Plot the Maps:

dat_f%>%
        leaflet()%>%
        addTiles()%>%
        addMarkers(lng = dat_f$Begin_Lon,lat = dat_f$Begin_Lat,
                   popup = as.character(dat_f$Total_cost),clusterOptions = markerClusterOptions())%>%
        addCircleMarkers(lng = dat_f$Begin_Lon,lat = dat_f$Begin_Lat,
                         weight = 1, radius = log10(dat_f$Total_cost),color = dat_f$Color,
                         ) %>%
        addLegend(labels = c("Flood","Thunderstorm Wind","Marine Thunderstorm Wind"),colors = c("blue","orange","yellow"))