addcov2mask: Add covariates to mask from raster data

Description Usage Arguments Details Value Examples

Description

Adds covariates to a habitat mask from a GIS landcover data in raster format.

Usage

1
2
addcov2mask(mask, raster, names = NULL, distance.to = NULL, drop = NULL,
  plot = TRUE, cols = NULL, domulti = FALSE)

Arguments

mask

mask object (as used by secrgam.fit and secr.fit)

raster

list with components x,y, and z in the same style as used by contour, persp, image etc. x and y are the X and Y grid values and z is a matrix with the corresponding values of the surface (this gets passed to interp.surface)

names

names to associate with the values in raster (for multiple layer types)

distance.to

names of any layers for which ‘distance to’ covariates are to be calcuated

drop

names of layers to be deleted from the mask

plot

if TRUE then an image plot will be drawn using prep4image

cols

colours to associate with the layers (only used if plot = TRUE)

domulti

logical for categorical integer variable (like land use class) into columns of binary data for each category at each mask point if TRUE. If FALSE then treats creates a single column with the integer integer values.

Details

NOTE: This is a function under development, with rather limited and specific functionality. The secr function addCovariates is probably more useful at this stage. If typeof(raster$z) = "double" then elements of raster$z are assumed to represent a single layer type. If typeof(raster$z) = "integer" then each unique integer is assumed to represent a unique landcover type. If the mask already contains covariates whose names are identical to those supplied in names then these will be overwritten.

Value

Returns a new mask object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# load mask and raster data
data(Boland.leopards1)
data(Boland.landuse.image)
data(Boland.alt.image)

# save par settings
op = par(no.readonly = TRUE)

# single landcover type
par(mfrow = c(1,1), mar = c(2,2,2,2), oma = c(0,0,0,0))
newmask = addcov2mask(Boland.mask1, Boland.alt.image, "altitude")
head(covariates(newmask))

# mutiple landcover types
newmask = addcov2mask(
  Boland.mask1, Boland.landuse.image,
  names = c("Unknown", "Natural", "Cultivated", "Degraded", "Urban", "Water", "Plantation"),
  cols = c("black", "green3", "yellow", "tan", "dimgray", "blue", "gold2"),
)
head(covariates(newmask))

# mutiple landcover types - including distance to water and urbarn
par(mfrow = c(1,3))
newmask = addcov2mask(
  Boland.mask1, Boland.landuse.image,
  names = c("Unknown", "Natural", "Cultivated", "Degraded", "Urban", "Water", "Plantation"),
  cols = c("black", "green3", "yellow", "tan", "dimgray", "blue", "gold2"),
  distance.to = c("Urban","Water")
)
head(covariates(newmask))

# mutiple landcover types - including distance to water and urbarn (and deleting these mask points)
newmask = addcov2mask(
  Boland.mask1, Boland.landuse.image,
  names = c("Unknown", "Natural", "Cultivated", "Degraded", "Urban", "Water", "Plantation"),
  cols = c("black", "green3", "yellow", "tan", "dimgray", "blue", "gold2"),
  distance.to = c("Urban","Water"),
  drop = c("Urban","Water")
)
head(covariates(newmask))

# reset par settings
par(op)

david-borchers/secrgam documentation built on May 14, 2019, 9:30 p.m.