Returns a matrix of distances between every point and every other point of given river locations (segment and vertex), or of a subset.

riverdistancemat(seg, vert, rivers, logical = NULL, ID = NULL,
  stopiferror = TRUE, algorithm = NULL)

Arguments

seg

A vector of river locations (segment component).

vert

A vector of river locations (vertex component).

rivers

The river network object to use.

logical

A boolean vector that can be used for subsetting. If used, riverdistancemat will only return pairwise distances in which a specified condition is met.

ID

a vector of observation IDs for aid in interpreting the output table

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 distances (numeric) with rows and columns labeled by corresponding values of ID.

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

riverdistance

Examples

data(Gulk, fakefish) logi1 <- (fakefish$flight.date==as.Date("2015-11-25")) riverdistancemat(seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, logical=logi1)
#> 91 92 93 94 95 96 97 #> 91 0.000 114024.928 120991.401 47578.972 5331.438 98550.78 56658.868 #> 92 114024.928 0.000 6966.473 66445.955 108693.489 15474.15 57366.060 #> 93 120991.401 6966.473 0.000 73412.429 115659.963 22440.63 64332.533 #> 94 47578.972 66445.955 73412.429 0.000 42247.534 50971.80 9079.896 #> 95 5331.438 108693.489 115659.963 42247.534 0.000 93219.34 51327.430 #> 96 98550.776 15474.152 22440.625 50971.803 93219.337 0.00 41891.908 #> 97 56658.868 57366.060 64332.533 9079.896 51327.430 41891.91 0.000 #> 98 89172.366 24852.562 31819.035 41593.393 83840.928 9378.41 32513.498 #> 99 3836.327 117861.255 124827.728 51415.300 9167.765 102387.10 60495.195 #> 100 55326.842 58698.086 65664.559 7747.869 49995.403 43223.93 1332.026 #> 98 99 100 #> 91 89172.37 3836.327 55326.842 #> 92 24852.56 117861.255 58698.086 #> 93 31819.04 124827.728 65664.559 #> 94 41593.39 51415.300 7747.869 #> 95 83840.93 9167.765 49995.403 #> 96 9378.41 102387.103 43223.934 #> 97 32513.50 60495.195 1332.026 #> 98 0.00 93008.693 33845.524 #> 99 93008.69 0.000 59163.169 #> 100 33845.52 59163.169 0.000