extract.rast: A function for extracting raster data using an oSCR state...

View source: R/extract.rast.R

extract.rastR Documentation

A function for extracting raster data using an oSCR state space (ssDF) object.

Description

The function extracts data from a raster based uding X Y coordinated of the oSCR state space (ssDF) object using and appends the data to the existing data frame. The function will take multi session state space objects as input. The resolution of the raster summarires are defined by the discretization resolution of the state space.

Usage

extract.rast(ss, rast, mult = 1, cov.name = "val.1", func = median)

Arguments

ss

An oSCR state space object, ssDF.

rast

A raster containing data from which density covariates are to be extracted.

mult

A multiplier used scale ssDF coordinated to the coordinate scale of the raster.

cov.name

The name that will be given to the generated covariate.

func

The function used to summarise the raster within the ssDF generated raster.

Author(s)

Chris Sutherland

Examples


Mink - NLCD example to go here soon!
## The function is currently defined as
function (ss, rast, mult = 1, cov.name = "val.1", func = median) 
{
    for (i in 1:length(ss)) {
        tmpS <- ss[[i]][, c("X", "Y")] * mult
        id <- factor(1:nrow(tmpS))
        tmpR <- cbind(tmpS, id)
        aa <- rasterFromXYZ(tmpR, crs = projection(rast))
        bb <- rasterToPolygons(aa)
        r1 <- extract(rast, bb, fun = func)
        ss[[i]][, cov.name] <- r1
    }
    return(ss)
  }

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