Create haul level trip distance variable
Arguments
- dat
Primary data containing information on hauls or trips. Table in the FishSET database contains the string 'MainDataTable'.
- project
Project name.
- port
Port data frame. Contains columns: Port_Name, Port_Long, Port_Lat. Table is generated using the
load_port
function and saved in the FishSET database as the project and port, for example 'pollockPortTable'.- trip_id
Unique trip identifier in
dat
.- starting_port
Variable in
dat
containing ports at the start of the trip.- starting_haul
Character string, variables containing latitude and longitude at start of haul in
dat
.- ending_haul
Character string, variables containing latitude and longitude at end of haul in
dat
.- ending_port
Variable in
dat
containing ports at the end of the trip.- haul_order
Variable in
dat
that identifies haul order within a trip. Can be time, coded variable, etc.- name
String, name of created variable. Defaults to `TripDistance`.
- a
Numeric, major (equatorial) radius of the ellipsoid. The default value is for WGS84 ellipsoid.
- f
Numeric, ellipsoid flattening. The default value is for WGS84 ellipsoid.
Details
Summation of distance across a trip based on starting and ending ports and hauls in between.
The function uses distGeo
from the geosphere package to calculate distances
between hauls. Inputs are the trips, ports, and hauls from the primary dataset, and the latitude and
longitude of ports from the port
. The ellipsoid arguments, a
and f
, are numeric
and can be changed if an ellipsoid other than WGS84 is appropriate. See the geosphere R package for more details
(https://cran.r-project.org/web/packages/geosphere/geosphere.pdf).