Simple network computation of distance between points along linear landscape features (e.g. rivers).

1 | ```
networkdistance(xy1, xy2, geometry)
``` |

`xy1` |
2-column matrix or dataframe |

`xy2` |
2-column matrix or dataframe |

`geometry` |
‘linearmask’ object |

`networkdistance`

computes the distance in metres between the
points in `xy1`

and the points in `xy2`

. The `geometry`

is a linearmask; if it is missing then it takes the value of `xy2`

,
which then of course must be a full linearmask. A network is taken from
the ‘graph’ attribute of `geometry`

or (if necessary) constructed
from the linearmask ‘on the fly’, joining any points closer than
(`spacingfactor`

x `spacing(geometry)`

). Points in `xy1`

and `xy2`

are first snapped to the nearest point in
`geometry`

. The computed distance is the sum of the graph's edge
weights along the shortest path joining two points.

The commonest use of `networkdistance`

is to calculate distances
between detectors (traps) and points on a linear mask. In this case it
is sufficient to provide two arguments only, as `xy2`

serves as
both destination and geometry.

`networkdistance`

meets the requirements for a user-defined
distance function (userdist) in secr. No parameter is estimated.

Use `showpath`

to check network distances interactively.

`networkdistance`

–

given *k* detectors and *m* mask
points, a *k* x *m* matrix of distances.

If called with no arguments `networkdistance`

returns a
zero-length character vector.

`read.linearmask`

, `showpath`

,
`asgraph`

1 2 3 4 5 6 7 8 9 | ```
x <- seq(0, 4*pi, length = 200)
xy <- data.frame(x = x*100, y = sin(x)*300)
mask <- read.linearmask(data = xy, spacing = 20)
trps <- make.line(mask, n = 15, startbuffer = 1000, by = 30)
## networkdistance; geometry in 'mask'
d <- networkdistance (trps, mask, mask)
dim(d)
head(d)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.