tc_raster() is a helper function that returns the raster template used to construct the graph. tc_adj_matrix() is a helper function that returns the adjacency matrix that underlies the graph.

tc_build_graph(x, directed = TRUE, neighbours = 8, wrap_x = FALSE)

tc_raster(x)

tc_adj_matrix(x)

Arguments

x

Raster: a raster layer defining the extent, projection, and resolution of the grid

directed

logical: if TRUE, the graph is directed (meaning that the cost of travel from cell x to cell y is not necessarily the same as the cost of travel from cell y to cell x)

neighbours

integer: either 4 (each cell is connected to its cardinal neighbours) or 8 (each cell is connected to all 8 neighbouring cells) or 16 (8 neighbouring cells plus the next 8 that do not lie in cardinal or directly diagonal directions)

wrap_x

logical: if TRUE, the graph is wrapped in the x direction (appropriate if the grid represents the full 360 longitude span of the globe)

Value

An object of class tc_graph

See also

Examples

my_raster <- raster::raster(ext = raster::extent(c(152.75, 155.25, -56.25, -54.25)), res = c(0.5, 0.5), crs = "+proj=longlat") g <- tc_build_graph(my_raster)