R/stack.R

Defines functions .createTData

#' @aliases stack,TransitionLayer-method
#' @aliases stack,TransitionStack-method
#' @author Jacob van Etten
setMethod("stack", signature(x="TransitionLayer"), function(x, ...)
{
  newStack <- as(x, "TransitionStack")
  objectList <- list(...)
  TData <- .createTData(x, objectList)
  newStack@transition <- TData
  return(newStack)
}
)

setMethod("stack", signature(x='TransitionStack'), function(x, ...)
{
  newStack <- as(x, "TransitionStack")
  objectList <- list(...)
  TData <- .createTData(x, objectList)
  newStack@transition <- TData
  return(newStack)
}
)

.createTData <- function(x, objectList)
{
  nobj <- length(objectList)
  if(nobj<1) {stop("more than one object is needed to stack")}
  TD <- transitionData(x)
  for(i in 1:nobj) {TD <- c(TD,transitionData(objectList[[i]]))}
  return(TD)
}

Try the gdistance package in your browser

Any scripts or data that you put into this service are public.

gdistance documentation built on July 9, 2023, 5:51 p.m.