afsc-gap-products / data-requests

An empty repo for tracking requests for GAP data
0 stars 0 forks source link

NBS design-based index of abundance for YFS, pollock, cod, and snow crab #97

Closed sean-rohan-NOAA closed 4 weeks ago

sean-rohan-NOAA commented 1 month ago

Data product requested: Design-based indies of abundance for the Northern Bering Sea from 2010-2023. For the NBS ESR Report Card

Output type: .csv

Species: yellowfin sole, pollock, cod, and snow crab

Region : Northern Bering Sea

Research team making the request: Ebett Siddon

sean-rohan-NOAA commented 1 month ago

Completed cod, YFS, and pollock. Requested snow crab from Kodiak.

# Retrieve NBS biomass index data for NBS Report Card
# Requested by: Ebett Siddon
# Prepared by Sean Rohan
# Date: 8/29/2024

library(gapindex)

channel <- gapindex::get_connected()

fish_query <- 
"SELECT 
  a.DESCRIPTION AS AREA_DESCRIPTION,
  b.YEAR, 
  tc.COMMON_NAME,
  b.SPECIES_CODE, 
  b.BIOMASS_MT, 
  b.BIOMASS_VAR, 
  b.POPULATION_COUNT, 
  b.POPULATION_VAR
FROM
  GAP_PRODUCTS.BIOMASS b,
  GAP_PRODUCTS.TAXONOMIC_CLASSIFICATION tc,
  GAP_PRODUCTS.AREA a
WHERE
  b.SPECIES_CODE in (10210, 21720, 21740)
  AND b.SURVEY_DEFINITION_ID = 143
  AND b.AREA_ID = 99902
  AND tc.SPECIES_CODE = b.SPECIES_CODE
  AND tc.SURVEY_SPECIES = 1
  AND a.SURVEY_DEFINITION_ID = b.SURVEY_DEFINITION_ID
  AND a.AREA_ID = b.AREA_ID"

nbs_fish <- RODBC::sqlQuery(channel = channel,
                            query = fish_query)

write.csv(nbs_fish, 
          file = here::here("2024-08-29 Ebett Siddon", "nbs_fish_biomass_siddon_20240829.csv"),
          row.names = FALSE)
sean-rohan-NOAA commented 4 weeks ago

Shannon Hennessey completed crab request.