travelTime: Calculate travel times between coordinates

travelTimeR Documentation

Calculate travel times between coordinates

Description

Using a friction raster (giving time taken to cross each cell) calculate the time taken to travel between pairs of coordinates.

Usage

travelTime(friction, coords, coords2 = NULL, directions = 8, ...)

Arguments

friction

a RasterLayer object with cell values giving the time taken to traverse that cell.

coords

a two-column matrix or dataframe, or a SpatialPoints object, giving coordinates to compute travel time from. If coords2 = NULL, the a square matrix will be returned, giving travel time between these pairs of coordinates

coords2

an optional two-column matrix or dataframe, or a SpatialPoints object, giving coordinates to compute travel time to.

directions

directions in which cells are connected, can be either 4, 8, 16 or some other number. See adjacent for details

...

additional arguments to pass to transition.

Details

This is a thin wrapper around functionality in the gdistance R package to facilitate the constuction of travel time matrices for use in movement models.

Value

a matrix, with dimensions nrow(coords), nrow(coords) (If coords2 = NULL) or dimensions nrow(coords), nrow(coords2) otherwise

Examples

# create a dummy friction matrix, assuming travel time is
# inversely proportional to population density
data(kenya)
kenya10 <- raster::aggregate(kenya, 10, sum)
friction <- 1 / kenya10

# example coordinates
coords <- matrix(c(38, 37, 36, 1, 0, 2), ncol = 2)

# calculate travel time between them
tt <- travelTime(friction, as.data.frame(coords))
tt

SEEG-Oxford/movement documentation built on April 17, 2023, 4:17 p.m.