Show Sampling 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 station extended repeated area (20).

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

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

mapview(cc_grid, zcol="sta_dpos", layer.name = "sta_dpos") +
  mapview(cc_grid_ctrs, cex = 1)
d_casts <- cc_bottle %>% 
  group_by(lon, lat) %>% 
  summarize(
    n = n(),
    .groups = "drop") %>% 
  st_as_sf(
    coords = c("lon", "lat"), crs = 4326)

n_ply <- cc_grid %>% 
  st_join(d_casts) %>% 
  group_by(sta_key) %>% 
  summarize(
    n = sum(n))

n_pts <- cc_grid_ctrs %>% 
  left_join(
    n_ply %>% 
      st_drop_geometry() %>% 
      select(sta_key, n),
    by = "sta_key")

mapview(n_ply, zcol="n", layer.name = "n")
mapview(n_pts, cex="n", layer.name = "n")

Map contours

Map contours of an oceanographic variable from CTD cast 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 salin…¹ 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  Inf.e-324
#> 2 -134.  42.5 1972-05-16       2      10       20  11.2     32.9  109. Inf.e-324
#> 3 -134.  42.5 1972-05-16       2      20       20  10.9     32.9  110. Inf.e-324
#> 4 -134.  42.5 1972-05-16       2      30       20  10.6     32.9  110  Inf.e-324
#> 5 -134.  42.5 1972-05-16       2      50       20   9.97    32.9  108. Inf.e-324
#> 6 -134.  42.5 1972-05-16       2      55       20   9.83    32.9  107. Inf.e-324
#> # … with abbreviated variable name ¹​salinity

# show bounding polygon
# mapView(area_calcofi_extended)

# get map contours, aka isobands, of variable using generalized additive model (GAM)

v_ply_all <- map_contours(
  df = cc_bottle %>%
    filter(
      !is.na(t_degc)) %>% 
    group_by(lon, lat) %>% 
    summarize(v = mean(t_degc)), 
  ply = cc_grid_areas %>% 
    filter(area_dpos == "5,10,20"))
# show contour polygons on map 
mapView(v_ply_all, zcol="v", layer.name="temp(ºC)")