make.S: make.S

View source: R/make.S.R

make.SR Documentation

make.S

Usage

make.S(scrFrame, buffer, res, xy = NULL)

Arguments

scrFrame
buffer
res
xy

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (scrFrame, buffer, res, xy = NULL) 
{
    if (class(scrFrame) != "scrFrame") 
        stop("Need an object of class scrFrame to create the state space")
    if (is.null(xy)) 
        xy <- c(1, 2)
    if (res == NULL) 
        stop("You didnt provide a resolution value!")
    if (res == NULL) 
        stop("You didnt provide a buffer value!")
    S <- list()
    trpls <- scrFrame$traps
    for (i in 1:length(trpls)) {
        bl <- apply(trpls[[i]][, xy], 2, min)
        tr <- apply(trpls[[i]][, xy], 2, max)
        sxy <- expand.grid(seq(bl[1] - buffer, tr[1] + buffer, 
            res), seq(bl[2] - buffer, tr[2] + buffer, res))
        dd <- apply(e2dist(sxy, trpls[[i]][, xy]), 1, min)
        S[[i]] <- sxy[dd <= buffer, ]
    }
    return(S)
  }

jaroyle/oSCR documentation built on Sept. 23, 2023, 12:46 p.m.