Passer au contenu

Creates a dataframe of transitions between sites; detections are ordered by detection time, then "transitions" are identified as the period between the final detection at site x (possible "departure"), and the first detection (possible "arrival") at site y (ordered chronologically). Each row contains the last detection time and lat/lon of site x, first detection time and lat/lon of site y, distance between the site pair, time between detections, rate of movement between detections, and bearing between site pairs.

Utilisation

siteTrans(data, latCoord = "recvDeployLat", lonCoord = "recvDeployLon")

Arguments

data

a selected table from .motus data, eg. "alltagsGPS", or a data.frame of detection data including at a minimum variables for ts, motusTagID, tagDeployID, recvDeployName, and a latitude/longitude

latCoord

a variable with numeric latitude values, defaults to recvDeployLat

lonCoord

a variable with numeric longitude values, defaults to recvDeployLon

Valeur de retour

a data.frame with these columns:

  • fullID: fullID of Motus registered tag

  • ts.x: time of last detection of tag at site.x ("departure" time)

  • lat.x: latitude of site.x

  • lon.x: longitude of site.x

  • site.x: first site in transition pair (the "departure" site)

  • ts.y: time of first detection of tag at site.y ("arrival" time)

  • lat.y: latitude of site.y

  • lon.y: longitude of site.y

  • site.y: second site in transition pair (the "departure" site)

  • tot_ts: length of time between ts.x and ts.y (in seconds)

  • dist: total straight line distance between site.x and site.y (in metres), see sensorgnome::latLonDist() for details

  • rate: overall rate of movement (tot_ts/dist), in metres/second

  • bearing: bearing between first and last detection sites, see bearing function in geosphere package for more details

Exemples

# You can use either a selected tbl from .motus eg. "alltagsGPS", or a
# data.frame, instructions to convert a .motus file to all formats are below.

# download and access data from project 176 in sql format
# usename and password are both "motus.sample"
if (FALSE) sql.motus <- tagme(176, new = TRUE, update = TRUE)

# OR use example sql file included in `motus`
sql.motus <- tagme(176, update = FALSE, 
                   dir = system.file("extdata", package = "motus"))

# convert sql file "sql.motus" to a tbl called "tbl.alltags"
library(dplyr)
tbl.alltags <- tbl(sql.motus, "alltagsGPS") 
 
## convert the tbl "tbl.alltags" to a data.frame called "df.alltags"
 df.alltags <- tbl.alltags %>%
   collect() %>%
   as.data.frame()

# View all site transitions for all detection data from tbl file tbl.alltags
transitions <- siteTrans(tbl.alltags)

# View site transitions for only tag 16037 from data.frame df.alltags using
# gpsLat/gpsLon
transitions <- siteTrans(filter(df.alltags, motusTagID == 16037),
                           latCoord = "gpsLat", lonCoord = "gpsLon")