Appendix - Salmon Stock Assessment Data

Fisheries and Oceans Canada stock assessment data was accessed via the NuSEDS-New Salmon Escapement Database System through the Open Government Portal with results presented in Table 5.1 (Fisheries and Oceans Canada, n.d.). A brief memo on the data extraction process is available here.

# Run by hand to regenerate `data/inputs_raw/study_area_NuSEDS.csv`. Needs network.
#
# The snapshot URL is resolved from the catalogue rather than hardcoded. DFO
# republishes NuSEDS under a new date-stamped filename and the previous one 404s -
# the hardcoded `All Areas NuSEDS_20251103.zip` here was already dead by
# 2026-08, which is why the table stopped rendering and the prose was left
# pointing at a `Table ??`.

pkg_id <- "c48669a3-045b-400d-b730-48aafe8c5ee6"

res <- jsonlite::fromJSON(
  paste0("https://open.canada.ca/data/en/api/3/action/package_show?id=", pkg_id)
)$result$resources

# the all-areas zip, whatever it is called this month
url <- res$url[grepl("^All Areas NuSEDS.*\\.zip$", res$name)][1]

# ~10 MB zipped, ~230 MB unzipped, so keep it out of the repo entirely
tmp_zip <- fs::file_temp(ext = "zip")
tmp_dir <- fs::path_temp("nuseds")
download.file(url, tmp_zip, mode = "wb")
utils::unzip(tmp_zip, exdir = tmp_dir)

all_area_nuseds <- readr::read_csv(fs::dir_ls(tmp_dir, glob = "*.csv")[1])

# repo-relative and params-driven; this pointed at another repo and another region
form_pscis_2025 <- read.csv(fs::path("data/backup", params$project_year, params$gis_project_name, paste0("form_pscis_", params$project_year, ".csv")))


# Big study area so lets filter using the stream names from `form_pscis`
stream_names <- form_pscis_2025 |>
  dplyr::pull(stream_name) |>
  stringr::str_trim() |>
  # Must be upper case to match those in Nuseds
  stringr::str_to_upper() |>
  unique()

# we also need to add in these waterbodies that we didn't explicitly sample but are that heavy hitters in the project area
major_streams <- "BULKLEY|MORICE|ZYMOETZ|KISPIOX|KITSUMKALUM|SKEENA RIVER|SUSKWA|TELKWA|BABINE"

# Combine into one regex pattern
stream_names_regex <- c(stream_names, major_streams) |>
  stringr::str_c(collapse = "|")

# Filter Nuseds to just include streams we visited
study_area_streams <- all_area_nuseds |>
  # Constrain to DFO Area 4, the Skeena, BEFORE matching on name. Stream names
  # are not unique across the coast: WATERFALL CREEK, one of this season's two
  # reassessment sites, also names a Haida Gwaii stream in area 2E, which put 224
  # rows of another region's escapement in the table. Filtering by area is the
  # discriminator; the previous name-exclusion list (`SHORE|BIG|LITTLE`) was
  # tuned to the Fraser and does nothing here.
  dplyr::filter(stringr::str_detect(AREA, "^4")) |>
  dplyr::filter(stringr::str_detect(WATERBODY, stream_names_regex)) |>
  janitor::clean_names() |>
  dplyr::arrange(waterbody)

# worth eyeballing before the write - confirms nothing out of area crept in
check_names <- study_area_streams |>
  dplyr::distinct(area, waterbody)

## Burn to csv. Updated name so it's clear this contains only the study area streams.
study_area_streams |>
  readr::write_csv('data/inputs_raw/study_area_NuSEDS.csv')
Table 5.1: Fisheries and Oceans Canada stock assessment data for select watershed groups in the Skeena watershed. Data can be filtered to specific waterbodies, columns can be dragged to reorder and filtered/reordered table can be exported to csv/excel. NOTE: To view all columns in the table - please click on one of the sort arrows within column headers before scrolling to the right.