Name :- Arrvind Sethuraman ID:- S4205433
# Loading the two datasets
manta <- read_csv("manta-tow-by-reef.csv")
transects <- read_csv("ltmp_hc_sc_a_by_site.csv")
# Adding readable sector names to manta data
manta$SECTOR_LABEL <- NA
manta$SECTOR_LABEL[manta$SECTOR == "CA"] <- "Cairns"
manta$SECTOR_LABEL[manta$SECTOR == "CB"] <- "Capricorn-Bunker"
manta$SECTOR_LABEL[manta$SECTOR == "CG"] <- "Cape Grenville"
manta$SECTOR_LABEL[manta$SECTOR == "CL"] <- "Cooktown-Lizard Island"
manta$SECTOR_LABEL[manta$SECTOR == "CU"] <- "Cape Upstart"
manta$SECTOR_LABEL[manta$SECTOR == "IN"] <- "Innisfail"
manta$SECTOR_LABEL[manta$SECTOR == "PC"] <- "Princess Charlotte Bay"
manta$SECTOR_LABEL[manta$SECTOR == "PO"] <- "Pompey"
manta$SECTOR_LABEL[manta$SECTOR == "SW"] <- "Swain"
manta$SECTOR_LABEL[manta$SECTOR == "TO"] <- "Townsville"
manta$SECTOR_LABEL[manta$SECTOR == "WH"] <- "Whitsunday"
# Adding readable shelf labels
manta$SHELF_LABEL <- NA
manta$SHELF_LABEL[manta$SHELF == "I"] <- "Inshore"
manta$SHELF_LABEL[manta$SHELF == "M"] <- "Mid-shelf"
manta$SHELF_LABEL[manta$SHELF == "O"] <- "Outer shelf"
# Parsing year from YEAR_CODE in transects (format is 199192, we want 1991)
transects$REPORT_YEAR <- as.integer(substr(as.character(transects$YEAR_CODE), 1, 4))
nrow(manta)
## [1] 2646
nrow(transects)
## [1] 18540
# Aggregating to get average live coral cover per year across all reefs
yearly_coral <- manta %>%
group_by(REPORT_YEAR) %>%
summarise(avg_coral = mean(MEAN_LIVE_CORAL))
# Building the plotly line chart
chart1 <- plot_ly(
data = yearly_coral,
x = ~REPORT_YEAR,
y = ~avg_coral,
type = "scatter",
mode = "lines+markers",
line = list(color = "#0D6986", width = 2.5),
marker = list(color = "#0D6986", size = 6),
hovertemplate = "<b>Year:</b> %{x}<br><b>Avg Coral Cover:</b> %{y:.1f}%<extra></extra>"
) %>%
layout(
title = list(
text = "Great Barrier Reef Live Coral Cover (1993–2023)",
font = list(size = 16)
),
xaxis = list(title = "Year"),
yaxis = list(title = "Average Live Coral Cover (%)", range = c(0, 45)),
annotations = list(
list(
x = 2012, y = 13.1,
text = "Record low\n(2012)",
showarrow = TRUE,
arrowhead = 2,
ax = 40, ay = -40,
font = list(color = "#c0392b", size = 11)
),
list(
x = 2022, y = 35.5,
text = "Record high\n(2022)",
showarrow = TRUE,
arrowhead = 2,
ax = -50, ay = -30,
font = list(color = "#27ae60", size = 11)
)
),
plot_bgcolor = "white",
paper_bgcolor = "white",
width = 600
)
chart1
The Great Barrier Reef has experienced significant fluctuations in live coral cover over the past three decades. Coverage hit a record low of just 13% in 2012 following a series of cyclones and bleaching events, but has since recovered to a record high of 35% by 2022. However, this recovery is uneven across the reef, as the following charts reveal.
# Aggregating all three metrics by year
yearly_stressors <- manta %>%
group_by(REPORT_YEAR) %>%
summarise(
avg_live = mean(MEAN_LIVE_CORAL),
avg_dead = mean(MEAN_DEAD_CORAL),
avg_cots = mean(MEAN_COTS_PER_TOW)
)
# Building a dual-axis chart - coral cover on left axis, COTS on right
chart2 <- plot_ly(data = yearly_stressors) %>%
# Live coral - left axis
add_trace(
x = ~REPORT_YEAR, y = ~avg_live,
type = "scatter", mode = "lines+markers",
name = "Live Coral Cover (%)",
line = list(color = "#0D6986", width = 2.5),
marker = list(color = "#0D6986", size = 5),
hovertemplate = "<b>Year:</b> %{x}<br><b>Live Coral:</b> %{y:.1f}%<extra></extra>"
) %>%
# Dead coral - left axis
add_trace(
x = ~REPORT_YEAR, y = ~avg_dead,
type = "scatter", mode = "lines+markers",
name = "Dead Coral Cover (%)",
line = list(color = "#c0392b", width = 2, dash = "dash"),
marker = list(color = "#c0392b", size = 5),
hovertemplate = "<b>Year:</b> %{x}<br><b>Dead Coral:</b> %{y:.1f}%<extra></extra>"
) %>%
# COTS - right axis
add_trace(
x = ~REPORT_YEAR, y = ~avg_cots,
type = "scatter", mode = "lines+markers",
name = "COTS per Tow",
yaxis = "y2",
line = list(color = "#e67e22", width = 2, dash = "dot"),
marker = list(color = "#e67e22", size = 5),
hovertemplate = "<b>Year:</b> %{x}<br><b>COTS per Tow:</b> %{y:.2f}<extra></extra>"
) %>%
layout(
title = list(
text = "GBR Coral Cover vs Key Stressors (1993–2023)",
font = list(size = 16)
),
xaxis = list(title = "Year"),
yaxis = list(title = "Coral Cover (%)", range = c(0, 45)),
yaxis2 = list(
title = "COTS per Tow",
overlaying = "y",
side = "right",
range = c(0, 3)
),
legend = list(x = 0.01, y = 0.99),
annotations = list(
list(
x = 2017, y = 24.1,
text = "2017 mass bleaching event",
showarrow = TRUE,
arrowhead = 2,
ax = -70, ay = -40,
font = list(color = "#c0392b", size = 10),
yref = "y"
)
),
plot_bgcolor = "white",
paper_bgcolor = "white",
width = 600
)
chart2
Three key stressors have driven coral decline over time — dead coral coverage, Crown-of-Thorns Starfish (COTS) outbreaks, and thermal bleaching. The 2017 mass bleaching event is clearly visible as dead coral spiked sharply, while COTS outbreaks around 2000–2003 coincided with some of the steepest drops in live coral cover.
# Aggregating by sector and shelf
sector_shelf <- manta %>%
group_by(SECTOR_LABEL, SHELF_LABEL) %>%
summarise(avg_coral = mean(MEAN_LIVE_CORAL), .groups = "drop")
# Setting shelf order for consistent display
sector_shelf$SHELF_LABEL <- factor(
sector_shelf$SHELF_LABEL,
levels = c("Inshore", "Mid-shelf", "Outer shelf")
)
# Grouped bar chart
chart3 <- plot_ly(
data = sector_shelf,
x = ~SECTOR_LABEL,
y = ~avg_coral,
color = ~SHELF_LABEL,
colors = c("Inshore" = "#c0392b", "Mid-shelf" = "#e67e22", "Outer shelf" = "#0D6986"),
type = "bar",
hovertemplate = "<b>%{x}</b><br>Shelf: %{fullData.name}<br>Avg Coral Cover: %{y:.1f}%<extra></extra>"
) %>%
layout(
barmode = "group",
title = list(
text = "Average Coral Cover by GBR Region and Shelf Position",
font = list(size = 16)
),
xaxis = list(title = "Region", tickangle = -30),
yaxis = list(title = "Average Live Coral Cover (%)"),
legend = list(title = list(text = "Shelf Position")),
plot_bgcolor = "white",
paper_bgcolor = "white",
width = 600
)
chart3
Coral health varies significantly by both region and distance from shore.Outer shelf reefs consistently outperform inshore reefs, with Pompey’s outer reef averaging over 41% cover compared to just 6% for Cape Upstart’s inshore reefs. Inshore reefs face additional pressures from agricultural runoff and sediment — threats that don’t reach the outer shelf.
# Filtering to most recent survey year
manta_2023 <- manta[manta$REPORT_YEAR == 2023, ]
# Colouring reefs by coral cover - red = low, green = high
coral_pal <- colorNumeric(
palette = c("#c0392b", "#e67e22", "#f1c40f", "#0D6986"),
domain = manta_2023$MEAN_LIVE_CORAL
)
# Building leaflet map
chart4 <- leaflet(manta_2023) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addCircleMarkers(
lng = ~LONGITUDE,
lat = ~LATITUDE,
radius = 7,
fillColor = ~coral_pal(MEAN_LIVE_CORAL),
fillOpacity = 0.85,
color = "white",
weight = 1,
popup = ~paste0(
"<b>", REEF_NAME, "</b><br>",
"Region: ", SECTOR_LABEL, "<br>",
"Shelf: ", SHELF_LABEL, "<br>",
"Live Coral Cover: ", round(MEAN_LIVE_CORAL, 1), "%"
)
) %>%
addLegend(
position = "bottomright",
pal = coral_pal,
values = ~MEAN_LIVE_CORAL,
title = "Live Coral Cover (%)",
opacity = 0.85
)
chart4
The 2023 survey reveals a clear north-south divide in reef health across the Great Barrier Reef. Click any reef to see its exact coral cover — greener dots indicate healthier reefs, while red dots signal reefs under stress.
# Aggregating transects data by year and benthos group
benthos_yearly <- transects %>%
group_by(REPORT_YEAR, GROUP_CODE) %>%
summarise(avg_cover = mean(COVER), .groups = "drop")
# Setting a clear colour for each group
benthos_colours <- c(
"Hard Coral" = "#0D6986",
"Soft Coral" = "#5dade2",
"Algae" = "#27ae60",
"Other" = "#bdc3c7"
)
# Stacked area chart - shows composition change over time
chart5 <- plot_ly(
data = benthos_yearly,
x = ~REPORT_YEAR,
y = ~avg_cover,
color = ~GROUP_CODE,
colors = benthos_colours,
type = "scatter",
mode = "none",
stackgroup = "one",
groupnorm = "percent",
hovertemplate = "<b>%{fullData.name}</b><br>Year: %{x}<br>Share: %{y:.1f}%<extra></extra>"
) %>%
layout(
title = list(
text = "GBR Seafloor Composition Over Time (1991–2022)",
font = list(size = 16)
),
xaxis = list(title = "Year"),
yaxis = list(
title = "Share of Seafloor (%)",
ticksuffix = "%"
),
legend = list(title = list(text = "Benthos Type")),
annotations = list(
list(
x = 2011, y = 50,
text = "Algae dominates\nat reef lows",
showarrow = FALSE,
font = list(color = "white", size = 10)
)
),
plot_bgcolor = "white",
paper_bgcolor = "white",
width = 600
)
chart5
When coral declines, algae rapidly colonises the vacant seafloor. During the reef’s lowest point around 2011–2013, algae occupied nearly 70% of the seafloor. While hard coral has shown some recovery in recent years, algae continues to dominate — suggesting the reef’s ecosystem balance remains fragile.