Part B: Mapping Seismic Activity: Interactive Visualizations of Earthquake Data

Introduction

Earthquakes are one of the most impactful natural disasters, often causing widespread damage and loss of life. Understanding the spatial patterns and magnitudes of seismic activity is crucial for disaster risk management and preparedness. Using interactive mapping tools, we explore the distribution and intensity of earthquakes, highlighting patterns of seismic activity and clustering in specific regions. By leveraging the Leaflet package, we create dynamic maps that offer an intuitive way to interpret and analyze earthquake data, providing valuable insights into these natural phenomena.

Dataset Overview

I used the built-in ‘quakes’ dataset available in R, which includes information on earthquakes near Fiji since 1964. The key variables include:

  • ‘lat’ and ‘long’: Latitude and Longitude of the earthquake
  • ‘mag’: Earthquake magnitude on the Richter scale
  • ‘depth’: Depth of the earthquake in kilometers

Map 1: Earthquake Magnitudes

This map visualizes earthquake magnitudes greater that 4.5 and the magnitude is represented by the size and color of the circles, with a popup providing additional details about each earthquake.

The code for the first map creates an interactive Leaflet map visualizing earthquake magnitudes greater than 4.5. It first loads necessary libraries for mapping and data manipulation, then filters the quakes dataset to include only high-magnitude earthquakes. A color palette is defined using YlOrRd to represent earthquake magnitudes. The map is generated with circle markers, where marker size and color correspond to magnitude, and popups display additional earthquake details. A legend is added in the bottom right corner for clarity.

Code for Map 1

# Load required libraries 
library(leaflet)
library(dplyr)
library(htmlwidgets)
library(leaflet.extras)
library(sf)

# Filter earthquake data for map 1
quakes_filtered_1 <- quakes %>% filter(mag > 4.5)

# Define a color palette
pal_1 <- colorNumeric(palette = "YlOrRd", domain = quakes_filtered_1$mag)

# Create map 1
map1 <- leaflet(quakes_filtered_1) %>% 
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addCircleMarkers(
    lng = ~long, lat = ~lat,
    color = ~pal_1(mag),
    radius = ~mag * 2,
    popup = ~paste0("Magnitude: ", mag, "<br>Depth: ", depth, " km"),
    label = ~paste0("Magnitude: ", mag),
    fillOpacity = 0.7
  ) %>% 
  addLegend(
    pal = pal_1,
    values = ~mag,
    title = "Earthquake Magnitude",
    position = "bottomright"
  )
# Display the map
map1

Map 2: Clustered Earthquake Locations

This map uses marker clustering to represent earthquakes with magnitudes greater than 5.The clustering technique simplifies the visualization of highly dense areas for the user.

The code filters the quakes dataset to include only earthquakes with a magnitude greater than 5. It then creates an interactive Leaflet map using marker clustering, which groups nearby earthquake points to improve visualization. The CartoDB.Positron basemap is added for context. Each earthquake location is represented by a marker, and clicking a marker displays a popup with the earthquake’s magnitude and depth. The clusterOptions() function enables automatic clustering, making it easier to explore dense earthquake regions.

Code for Map 2

# Filter earthquake data for map 2
quakes_filtered_2 <- quakes %>% filter(mag > 5)

# Create map with marker clustering
map_with_clusters <- leaflet(quakes_filtered_2) %>% 
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addMarkers(
    lng = ~long, lat = ~lat,
    popup = ~paste0("Magnitude: ", mag, "<br>Depth: ", depth, " km"),
    clusterOptions = markerClusterOptions()
  )

map_with_clusters

Map 3: Heatmap with Data points

This map combines a heatmap and circle markers to represent the density of earthquake activity. It highlights the most seismically active regions, with popups providing detailed information about individual earthquakes.

This code chunk filters the quakes dataset to include earthquakes with a magnitude greater than 4.5. A blue color palette is defined to represent magnitudes on both a heatmap and individual points. The Leaflet map is created with a heatmap layer, where earthquake density is visualized with intensity-based shading. Circle markers are added to show individual earthquake locations, with popups displaying magnitude, depth, and coordinates. Additionally, a legend is included to help interpret the earthquake magnitudes.

Code for Map 3

# Filter earthquake data
quakes_filtered <- quakes %>% filter(mag > 4.5)

# Define a blue color palette for both the heatmap and the points
pal <- colorNumeric(palette = "Blues", domain = quakes_filtered$mag)

# Create the map with heatmap and translucent points
heatmap_with_points <- leaflet(quakes_filtered) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addHeatmap(
    lng = ~long, lat = ~lat,
    intensity = ~mag,
    blur = 20,
    max = 0.05,
    radius = 15
  ) %>%
  addCircleMarkers(
    lng = ~long, lat = ~lat,
    radius = 2,
    color = ~pal(mag),
    fillColor = ~pal(mag),
    fillOpacity = 0.6,
    weight = 0.5,
    popup = ~paste0(
      "<b>Magnitude:</b> ", mag, "<br>",
      "<b>Depth:</b> ", depth, " km<br>",
      "<b>Latitude:</b> ", lat, "<br>",
      "<b>Longitude:</b> ", long
    )
  ) %>%
  addLegend(
    pal = pal,
    values = ~mag,
    title = "Earthquake Magnitude",
    position = "bottomright"
  )

heatmap_with_points