travelTime | R Documentation |
Using a friction raster (giving time taken to cross each cell) calculate the time taken to travel between pairs of coordinates.
travelTime(friction, coords, coords2 = NULL, directions = 8, ...)
friction |
a |
coords |
a two-column matrix or dataframe, or a SpatialPoints object,
giving coordinates to compute travel time from. If |
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 |
... |
additional arguments to pass to
|
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.
a matrix, with dimensions nrow(coords), nrow(coords)
(If coords2 = NULL
) or dimensions nrow(coords), nrow(coords2)
otherwise
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.