extract.rast | R Documentation |
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.
extract.rast(ss, rast, mult = 1, cov.name = "val.1", func = median)
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. |
Chris Sutherland
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.