trans.mat: Transition matrix

View source: R/trans.mat.R

trans.matR Documentation

Transition matrix

Description

Creates a transition object to be used by lc.dist to compute least cost distances between locations.

Usage

trans.mat(bathy,min.depth=0,max.depth=NULL)

Arguments

bathy

A matrix of class bathy.

min.depth, max.depth

Numeric. The range of depth between which the path will be possible. The default (min.depth=0 and max.depth=NULL) indicates that the transition between cells of the grid is possible between 0 meters depth and the maximum depth of bathy. See details

Details

trans.mat creates a transition object usable by lc.dist to computes least cost distances between a set of locations. trans.mat rely on the function raster from package raster (Hijmans & van Etten, 2012. https://CRAN.R-project.org/package=raster) and on transition from package gdistance (van Etten, 2011. https://CRAN.R-project.org/package=gdistance).

The transition object contains the probability of transition from one cell of a bathymetric grid to adjacent cells and depends on user defined parameters. trans.mat is especially usefull when least cost distances need to be calculated between several locations at sea. The default values for min.depth and max.depth ensure that the path computed by lc.dist will be the shortest path possible at sea avoiding land masses. The path can be constrained to a given depth range by setting manually min.depth and max.depth. For instance, it is possible to limit the possible paths to the continental shelf by setting max.depth=-200. Inaccuracies of the bathymetric data can occasionally result in paths crossing land masses. Setting min.depth to low negative values (e.g. -10 meters) can limit this problem.

trans.mat takes also advantage of the function geoCorrection from package gdistance (van Etten, 2012. https://CRAN.R-project.org/package=gdistance) to take into account map distortions over large areas.

Value

A transition object.

Warning

Please be aware that the use of trans.mat can be time consumming for large bathymetric datasets. The function takes about one minute to compute a transition matrix for the hawaii bathymetric data (bathymetric data of class bathy with 599 rows and 419 columns, see hawaii) on a MacBook Pro with a 2.66 GHz Intel Core i7 processor and 4 Go of RAM.

Author(s)

Benoit Simon-Bouhet

References

Jacob van Etten (2011). gdistance: distances and routes on geographical grids. R package version 1.1-2. https://CRAN.R-project.org/package=gdistance Robert J. Hijmans & Jacob van Etten (2012). raster: Geographic analysis and modeling with raster data. R package version 1.9-92. https://CRAN.R-project.org/package=raster

See Also

lc.dist, hawaii

Examples

# Load and plot bathymetry
data(hawaii)
summary(hawaii)
plot(hawaii)

## Not run: 
# Compute transition object with no depth constraint
trans1 <- trans.mat(hawaii)

# Compute transition object with minimum depth constraint: 
# path impossible in waters shallower than -200 meters depth
trans2 <- trans.mat(hawaii,min.depth=-200)

# Visualizing results
par(mfrow=c(1,2))
plot(raster(trans1), main="No depth constraint")
plot(raster(trans2), main="Constraint in shallow waters")

## End(Not run)

marmap documentation built on March 31, 2023, 6:59 p.m.

Related to trans.mat in marmap...