trans.mat | R Documentation |
Creates a transition object to be used by lc.dist
to compute least cost distances between locations.
trans.mat(bathy,min.depth=0,max.depth=NULL)
bathy |
A matrix of class |
min.depth, max.depth |
Numeric. The range of depth between which the path will be possible. The default ( |
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.
A transition object.
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.
Benoit Simon-Bouhet
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
lc.dist
, hawaii
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.