Learn R Programming

gdistance (version 1.1-1)

transition: Create an object of the class Transition

Description

Create a Transition object from a RasterLayer or RasterBrick object. Transition values are calculated with a user-defined function from the grid values.

Usage

transition (object, transitionFunction, directions, ...)

Arguments

object
RasterLayer or RasterBrick (raster package)
transitionFunction
Function to calculate transition values from grid values
directions
Directions in which cells are connected (4, 8, 16, or other), see adjacency
...
Additional arguments, see below

Value

  • Transition object

Details

Users may use one of three methods to construct a Transition* object with this function. 1) TransitionLayer from RasterLayer transition(object, transisitonFunction, directions, symm) When a symmetric transition matrix is required, the user should supply a transitionFunction f that obeys f(i,j) = f(j,i) (a commutative function). The function transition does no commutativity check. To obtain an asymmetric transition matrix, a non-commutative function should be supplied and an additional argument `symm' should be set to FALSE. 2) TransitionLayer from RasterBrick transition(object, transisitonFunction="mahal", directions) This method serves to summarize several layers of data in a single distance measure. The distance between adjacent cells is the normalized reciprocal of the Mahalanobis distance (mean distance / (mean distance + distance ij). 3) TransitionStack from RasterLayer transition(object, transisitonFunction="barriers", directions, intervalBreaks) This method creates a TransitionStack with each layer containing a discrete boundary between areas in object. Areas are defined by intervals in object. The argument intervalBreaks is a vector of interval breaks corresponding to the values in object. If between a pair of cells i and j, min(i,j) < break AND max(i,j) > break, then the value ij in the transition matrix becomes 1. All other values in the transition matrix remain 0. In contrast with the above methods, this method produces resistance matrices by default. The package classInt offers several methods to define intervals.

Examples

Run this code
#Create a new raster and set all its values to unity.
  r <- raster(nrows=18, ncols=36) 
  r <- setValues(r, runif(ncell(r)))

  #Create a Transition object from the raster
  tr <- transition(r, transitionFunction=mean, directions=4)
  tr #the sparse matrix is of class dsCMatrix (symmetric)

  #Create an asymmetric transition matrix
  #first, an arbitrary non-commutative function 
  f <- function(x) max(x) - x[1] + x[2] 
  tr2 <- transition(r, f, 4, symm=FALSE)
  tr2 #the sparse matrix is of class dgCMatrix (=asymmetric)

Run the code above in your browser using DataLab