
Index Trips Whose Track Duplicates Another Trip
Source:R/aggregate-effort.R
index_trip_duplicates.RdFlags trips whose GPS track is identical to another trip's, so the same fishing event is not counted once per trip identifier.
Usage
index_trip_duplicates(df, prefer = character(0), seen = NULL)Arguments
- df
Prepared fishing points with one row per ping and columns
trip,timestamp,latitude,longitude.- prefer
Character vector of trip identifiers to keep in preference to others – normally the trips PDS still lists, which are the ones carrying device metadata. Defaults to none.
- seen
Optional data frame of trips aggregated in earlier runs, with columns
tripandfingerprint.
Value
A tibble with one row per trip in df: trip, fingerprint,
n_points, duplicate_of (the surviving trip, NA when the trip is
itself the survivor) and keep.
Details
Pelagic Data Systems re-segments trips retroactively. A trip identifier can
be retired (its points reappear under a new identifier) or reassigned
(its points move to a new trip while the old identifier comes to describe a
different window). Since predict_pds_tracks() writes one file per trip,
the predicted-track store ends up holding several identifiers that describe
the very same track, and aggregate_pds_effort() counts each of them as a
separate vessel: fishing hours, unique trips and pings are multiplied by the
number of copies, while n_active_days (a set union of dates) is not, so
the per-day rates in add_cell_effort_metrics() explode.
Each trip is reduced to a fingerprint of its (timestamp, latitude, longitude) triples, order-independent so that two files listing the same
points always agree. Trips sharing a fingerprint – with each other, or with
a trip aggregated in an earlier run (seen) – collapse to one survivor: a
trip listed in prefer wins, then the trip with the most points, then the
lowest identifier, so the choice is stable across runs.
A trip already in the effort store always outranks a new duplicate of it, so
that a run cannot move effort between trips that are known to be the same.
When a retired identifier is aggregated before the trip that supersedes it,
the retired one therefore survives and its cells keep gear/country =
"unknown"; the deletion pass in predict_pds_tracks() is what stops that
happening.