Moved from whalesafe4r/vignettes (3/10/2020)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = F,
  message = F,
  eval = T)

Load Santa Barbara AIS Ship Data

Load dataset sbais which got ingested from raw data at data-raw/2018-06-01_2018-06-07 by data-raw/sbais.R using read_ais_txt() in R/read.R.

And get top 20 vessels with data.

library(tidyverse)
library(shipr)
# devtools::install_local(force=T)
# devtools::document()
# devtools::load_all()

# show sbais dataset, lazy loaded
sbais

# explicitly attach to environment
data(sbais)

sbais %>% 
  group_by(name) %>% 
  summarize(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(20) %>% 
  DT::datatable()

Analyze Single Ship Data

ship_name <- "NAUTILUS"

dir_cache <- "~/tmp/shipr"

# show segments table
segs <- get_ship_segments(sbais, ship_name, dir_data = dir_cache)

# look at ship segments
hist(segs$seg_kmhr)
summary(segs$seg_kmhr)
which(segs$seg_kmhr>100)

Map Single Ship Line Segments with Speed

map_ship_segments(segs)

Breakdown Ship Speeds based on Compliance Threshold

lims <- get_ship_limits(segs, limit_knots = 10, ship_name, dir_data = dir_cache)

# show limits table
lims

map_ship_limits(lims)

Gauge

pct_dist_ok <- lims %>% 
  filter(label == "<= 10 knots") %>% 
  pull(pct_dist)

show_ship_gauge(pct_dist_ok)

Value Box

show_ship_box(pct_dist_ok)

Note: this value box doesn't really render outside flexdashboard environment.

Ship Report Card Directory and Cards

Here's an example of using these functions together to create:

TODO: Next

  1. Filter based on shipping lane area. Where are lanes shapefile or larger area to be defined as recommended slowdown area?

    r lanes <- readOGR("C:/Users/Caroline/Desktop/Caroline ArcGIS/shipping_lanes","shipping_lanes_combined")

  2. Compare average vessel speed inside and outside the slowdown area.

  3. Convert km per hour (kmhr) to knots in segment outputs.

  4. Loop through rendering all ship cards using parameterized ship_card.Rmd

  5. Create directory page to ship cards and summary table of ship stats.

  6. Relate ships to organizations.

  7. Provide overview statistics for study area.



BenioffOceanInitiative/shipr documentation built on Aug. 10, 2020, 1:39 a.m.