Description Usage Arguments Value Examples
Calculates and returns the coordinates of the shortest path between two
points, taking into account a TransitionLayer
generated by the
leastCostMap
function.
1 | shortPath(from, to, depth.cost, simp.tol = 10)
|
from, to |
vectors with the (x, y) coordinates of the initial and final points |
depth.cost |
|
simp.tol |
Tolerance ( |
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.