Returns a matrix of upstream travel distance between all observations of one unique fish.

upstreammatbysurvey(indiv, unique, survey, seg, vert, rivers, full = TRUE,
  flowconnected = FALSE, net = FALSE, stopiferror = TRUE,
  algorithm = NULL)

Arguments

indiv

The unique identifier of the fish in question.

unique

A vector of identifiers for each fish.

survey

A vector of identifiers for each survey. It is recommended to use a numeric or date format (see as.Date) to preserve survey order.

seg

A vector of river locations (segment component).

vert

A vector of river locations (vertex component).

rivers

The river network object to use.

full

Whether to return the full matrix, with NA values for missing data (TRUE), or a the subset of rows and columns corresponding to successful observations. Defaults to TRUE.

flowconnected

If TRUE, only returns direction if the input segments are flow-connected. Defaults to FALSE.

net

Whether to calculate net upstream distance (net=TRUE) or total distance (net=FALSE, default).

stopiferror

Whether or not to exit with an error if a route cannot be found. If this is set to FALSE and a route cannot be found, the function will return NA in the appropriate entry. Defaults to TRUE. See detectroute.

algorithm

Which route detection algorithm to use ("Dijkstra", "sequential", or "segroutes"). If left as NULL (the default), the function will automatically make a selection. See detectroute for more details.

Value

A matrix of upstream distances (numeric), with rows and columns defined by survey. In the resulting matrix, the element with the row identified as A and column identified as B is defined as the upstream distance traveled from survey A to survey B. Therefore, it is likely that only the upper triangle of the matrix will be of interest.

Note

Building routes from the river mouth to each river network segment and/or distance lookup tables will greatly reduce computation time (see buildsegroutes).

See also

upstream

Examples

data(Gulk, fakefish) upstreammatbysurvey(indiv=1, unique=fakefish$fish.id, survey=fakefish$flight, seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk)
#> 1 2 3 4 5 6 7 8 9 #> 1 0.00 95083.922 NA 104647.183 136363.88 NA NA 79431.13 74981.17 #> 2 -95083.92 0.000 NA 9563.261 41279.96 NA NA -74322.80 -20102.75 #> 3 NA NA NA NA NA NA NA NA NA #> 4 -104647.18 -9563.261 NA 0.000 31716.70 NA NA -83886.06 -29666.01 #> 5 -136363.88 -41279.962 NA -31716.701 0.00 NA NA -115602.76 -61382.72 #> 6 NA NA NA NA NA NA NA NA NA #> 7 NA NA NA NA NA NA NA NA NA #> 8 -79431.13 74322.799 NA 83886.060 115602.76 NA NA 0.00 -54220.05 #> 9 -74981.17 20102.754 NA 29666.015 61382.72 NA NA 54220.05 0.00 #> 10 -38838.20 56245.722 NA 65808.983 97525.68 NA NA 40592.93 36142.97 #> 10 #> 1 38838.20 #> 2 -56245.72 #> 3 NA #> 4 -65808.98 #> 5 -97525.68 #> 6 NA #> 7 NA #> 8 -40592.93 #> 9 -36142.97 #> 10 0.00
upstreammatbysurvey(indiv=1, unique=fakefish$fish.id, survey=fakefish$flight, seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, full=FALSE)
#> 1 2 4 5 8 9 10 #> 1 0.00 95083.922 104647.183 136363.88 79431.13 74981.17 38838.20 #> 2 -95083.92 0.000 9563.261 41279.96 -74322.80 -20102.75 -56245.72 #> 4 -104647.18 -9563.261 0.000 31716.70 -83886.06 -29666.01 -65808.98 #> 5 -136363.88 -41279.962 -31716.701 0.00 -115602.76 -61382.72 -97525.68 #> 8 -79431.13 74322.799 83886.060 115602.76 0.00 -54220.05 -40592.93 #> 9 -74981.17 20102.754 29666.015 61382.72 54220.05 0.00 -36142.97 #> 10 -38838.20 56245.722 65808.983 97525.68 40592.93 36142.97 0.00