For the second part of this assignment I used a csv of point data of flash flooding events in the state of Florida to create an interactive map using R’s leaflet package. This data contains information on all flash flooding events that occurred in the state of Florida from 2015 to 2022such as the begin date of the event, the latitude and longitude of where each event begins, and the amount of property damage that was caused by each event. This information will be used in the interactive map to display distribution of flash flooding events in the state of Florida within this time period and assess where and when high damage occurred.
A few libraries will be used in part B. These are loaded below.
library(leaflet)
library(sf)
library(tidyverse)
library(leafem)
library(leafpop)
To create this map, the flooding data needs to be read in as spatial data using the appropriate latitude and longitude fields. Additionally, only the necessary fields will be selected for this map.
#Read in point data
(floods = read_csv('floods.csv') |>
st_as_sf(coords = c("BEGIN_LON", "BEGIN_LAT"), crs = 4326) |>
select(location = `BEGIN_LOCATION`, bdate = `BEGIN_DATE`, damage = `DAMAGE_PROPERTY_NUM`))
## Simple feature collection with 500 features and 3 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -87.49 ymin: 25.5687 xmax: -80.0501 ymax: 30.9876
## Geodetic CRS: WGS 84
## # A tibble: 500 × 4
## location bdate damage geometry
## <chr> <chr> <dbl> <POINT [°]>
## 1 JENSEN BEACH 2/28/2015 105000 (-80.2 27.26)
## 2 LEMON CITY 2/28/2015 3000 (-80.1954 25.8111)
## 3 CHIPLEY 4/12/2015 0 (-85.537 30.7881)
## 4 STEELE CITY 4/12/2015 2000 (-85.4158 30.7244)
## 5 COTTONDALE 4/12/2015 2000 (-85.3613 30.8221)
## 6 COTTONDALE 4/12/2015 2000 (-85.4149 30.797)
## 7 COTTONDALE 4/12/2015 2000 (-85.3467 30.8385)
## 8 SIMSVILLE 4/12/2015 5000 (-85.2401 30.6681)
## 9 KYNESVILLE 4/12/2015 5000 (-85.3111 30.6771)
## 10 ROUND LAKE 4/12/2015 5000 (-85.3954 30.6597)
## # ℹ 490 more rows
With this data, we can create an interactive map showing all the locations of flash floods. Symbol color is used to represent the level of damage caused by each event. Hovering over an event shows the beginning date of the event. Clicking on a point shows a popup containing information on the pertinent fields.
#Color map creation
pal <- colorNumeric(palette = "YlOrRd",domain = floods$damage)
#Create Map
leaflet(data=floods) |>
addTiles() |> #Add open street map basemap
addCircleMarkers(
color = ~pal(damage), fillOpacity = .50, #add color pallete based on damage value for symbols
stroke = FALSE,
label = ~bdate, #add label
popup = leafpop::popupTable(st_drop_geometry(floods[,1:4]), feature.id = FALSE, row.numbers = FALSE) #add popup table
) |>
addLegend("bottomleft",pal=pal, values = ~damage)#Add legend
As seen in the map, most events cause little to no property damage. There are a few high damage events on the southeast coast. These are the highest damage events which could be likely due to the high population of these areas. There is a lot more that can get damaged if there is a higher amount of infrastructure in an area. But since there are other events in the same area causing less damage. These events likely were caused by stronger weather circumstances overall. A couple of other high damage events are in the panhandle region and exploring these shows that they all occurred on the same day. This could mean that all of these flash floods were caused by the same weather event.