Show Effort

The CalCOFI grid (cc_grid) and centroids (cc_grid_ctrs) show the CalCOFI Station Positions – CalCOFI at varying separation distances of station positions (sta_dpos) in the CalCOFI coordinate system from nearshore (5), to offshore (10) to outside the 113 extended station pattern to historically visited areas (20).

This allows summarization of effort within each station and defining a study area according to these criteria (e.g., sta_dpos).

Grid by Zone

library(calcofi4r)
library(dplyr)
library(mapview)
library(sf)
library(stars)

mapview(cc_grid, zcol="zone_key") +
  mapview(cc_grid_ctrs, cex = 1)

Summarize Temperature from Bottle Data

# show first 6 rows of example data frame with temperature in space as variable
head(cc_bottle)
#> # A tibble: 6 × 10
#>     lon   lat date       quarter depth_m sta_dpos t_degc salinity o2sat       n
#>   <dbl> <dbl> <date>       <int>   <dbl>    <dbl>  <dbl>    <dbl> <dbl> <int64>
#> 1 -134.  42.5 1972-05-16       2       0       20  11.2      32.9  109        1
#> 2 -134.  42.5 1972-05-16       2      10       20  11.2      32.9  109.       1
#> 3 -134.  42.5 1972-05-16       2      20       20  10.9      32.9  110.       1
#> 4 -134.  42.5 1972-05-16       2      30       20  10.6      32.9  110        1
#> 5 -134.  42.5 1972-05-16       2      50       20   9.97     32.9  108.       1
#> 6 -134.  42.5 1972-05-16       2      55       20   9.83     32.9  107.       1

# summarize temperature by location and convert to points
d_t <- cc_bottle %>% 
  filter(
    !is.na(t_degc)) %>% 
  group_by(lon, lat) %>% 
  summarize(
    n = n(),
    v = mean(t_degc),
    .groups = "drop") %>% 
  st_as_sf(
    coords = c("lon", "lat"), remove = F,
    crs = 4326)

Show Effort by Grid Cell

n_ply <- cc_grid %>% 
  st_join(d_t) %>% 
  group_by(sta_key) %>% 
  summarize(
    n = sum(n))
mapview(n_ply, zcol="n", layer.name = "n")

Show Effort by Grid Point

n_pts <- cc_grid_ctrs %>% 
  left_join(
    n_ply %>% 
      st_drop_geometry() %>% 
      select(sta_key, n),
    by = "sta_key")
mapview(n_pts, cex="n", layer.name = "n")