tc_cost.Rd
Calculate the travel cost from one or more points to each point on a raster
tc_cost(x, from, direction = "out")
x | tc_graph: an object of class |
---|---|
from | numeric or matrix: the points to calculate travel costs from. A two-element numeric vector or a 2-column matrix, or anything else accepted by |
direction | string:
|
A raster layer (if from
is one point) or brick (if from
is more than one point)
my_raster <- raster::raster(ext = raster::extent(c(153, 155, -56, -54)), res = c(0.5, 0.5), crs = "+proj=longlat") g <- tc_build_graph(my_raster) ## set random edge weights g <- tc_set_edge_weights(g, values = runif(sum(tc_adj_matrix(g) > 0))) ## calculate travel cost cx <- c(154, -55) D <- tc_cost(g, from = cx)