conductance_surface: Create a parameterized conductance surface

Description Usage Arguments Details Value References See Also Examples

View source: R/radish_graph.R

Description

Given a set of spatial covariates and a set of spatial coordinates, create a graph representing a parameterized conductance surface.

Usage

1
conductance_surface(covariates, coords, directions = 4, saveStack = TRUE)

Arguments

covariates

A RasterStack containing spatial covariates

coords

A SpatialPoints object containing coordinates for a set of focal cells, with the same projection as the rasters in covariates

directions

If 4, consider only horizontal/vertical neighbours as adjacent; if 8, also consider diagonal neighbours as adjacent

saveStack

If TRUE, the RasterStack is returned with missing data masked uniformly across rasters

Details

NAs are shared across rasters in covariates, and a warning is thrown if a given cell has mixed NA and non-NA values across the stack. Comparing models with different patterns of missing spatial data (e.g. fit to different stacks of rasters) can give superficially inconsistant results, as these essentially involve different sets of vertices. Thus model comparison should use models fitted to the same radish_graph object.

Disconnected components are identified and removed, so that only the largest connected component in the graph is retained. The function aborts if there are focal cells that belong to a disconnected component.

Rasters of categorical covariates must have an associated RAT to be 'recognized' as categorical, see ratify and examples below. The names of levels are taken from the VALUE column of the RAT, if it exists (otherwise, the integer codes in the ID column are used).

Value

An object of class radish_graph

References

Pope NS. In prep. Fast gradient-based optimization of resistance surfaces.

See Also

radish, stack

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(raster)

data(melip)

covariates <- raster::stack(list(altitude=raster::scale(melip.altitude), 
                                 forestcover=raster::scale(melip.forestcover)))

surface <- conductance_surface(covariates, melip.coords, directions = 8)

# categorical covariates:
# rasters of categorical covariates must have an associated RAT, see 'details'
forestcover_class <- cut(raster::values(melip.forestcover), breaks = c(0, 1/3, 1/6, 1)) 
melip.forestcover_cat <- 
  raster::ratify(raster::setValues(melip.forestcover, as.numeric(forestcover_class)))

RAT <- levels(melip.forestcover_cat)[[1]]
RAT$VALUE <- levels(forestcover_class) #explicitly define level names
levels(melip.forestcover_cat) <- RAT

covariates_cat <- raster::stack(list(forestcover = melip.forestcover_cat,
                                     altitude = melip.altitude)) 

nspope/radish documentation built on July 12, 2020, 11:50 a.m.