shortPath: Get the shortest path between two points

Description Usage Arguments Value Examples

Description

Calculates and returns the coordinates of the shortest path between two points, taking into account a TransitionLayer generated by the leastCostMap function.

Usage

1
shortPath(from, to, depth.cost, simp.tol = 10)

Arguments

from, to

vectors with the (x, y) coordinates of the initial and final points

depth.cost

TransitionLayer returned by leastCostMap function.

simp.tol

Tolerance (tol) argument for the gSimplify function.

Value

A data frame with the x and y coordinates defining the shortest path between the two points, in the same geographic reference system as the depth.cost object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
library(raster)

depth.cost <- leastCostMap(bathymetry, min.depth = 20, max.depth = 30)
plot(raster(depth.cost))

from <- c(518201, 4655442)
to <-  c(518290, 4654591)

# Points can be also selected by directly clicking in the map
# from <- locator(1)
# to <- locator(1)

path <- shortPath(from = from, to = to, depth.cost = depth.cost)

points(rbind(from, to))
lines(path)

## End(Not run)

aspillaga/fishtrack3d documentation built on June 4, 2019, 9:14 a.m.