Description Usage Arguments Value Author(s) See Also Examples
View source: R/convertRaster.R
Create a habitat mask suitable for JAGS from a raster in which non-habitat is indicated by NAs. The raster is converted to a look-up matrix and included in the output.
1 | convertRaster(raster, traps, plot = TRUE)
|
raster |
An object of class |
traps |
A 2-column matrix or data frame with the x and y coordinates of the traps. |
plot |
If TRUE, the resulting mask and trap locations will be plotted. |
An object of class JAGSmask
, a list where the first elements are matrices corresponding to habMat with the values of the covariate in the original raster layer or stack. NA values in the raster are replaced with 0. If raster
is a RasterLayer, this will be names 'covMat', otherwise the names of the layers will be retained.
This is followed by the following items
habMat |
A 1/0 matrix, |
trapMat |
A 2-column matrix with the x and y coordinates of the traps in the same units as |
upperLimit |
A length 2 vector giving the upper limit of x and y for |
pixelWidth |
The width and height of the cells in |
area |
The area of suitable habitat in the original units, typically square metres. |
It will also have the following attributes, which can be used to convert JAGS output back to the original coordinate system:
boundingbox |
A 4x2 matrix with coordinates of the 4 corners of |
origin |
A vector of length 2 giving the location in the original coordinates of point 0, 0 in pixel units. |
Mike Meredith
1 2 3 4 5 6 7 8 9 10 11 12 | require(raster)
data(simSCR)
plot(simSCR$patchR)
points(simSCR$traps, pch=3, col='red')
plot(simSCR$patchRS)
# Create the 'JAGSmask' object from the raster:
mymask1 <- with(simSCR, convertRaster(patchR, traps, plot=TRUE))
str(mymask1) # covariate is called "covMat"
mymask2 <- with(simSCR, convertRaster(patchRS, traps, plot=TRUE))
# only the first covariate is shown
str(mymask2) # covariates retain the names in the RasterStack
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.