linkNode: Link nodes to spatial data

Description Usage Arguments Details Value See Also Examples

View source: R/linkNode.R

Description

linkNode links a node of the Bayesian network to the corresponding spatial data, returning a list of objects, including the spatial data and relevant info about the node.
linkMultiple operates on multiple nodes and related spatial data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
linkNode(
  layer,
  network,
  node,
  intervals,
  categorical = NULL,
  field = NULL,
  verbose = TRUE,
  spatial = TRUE
)

linkMultiple(spatialData, network, lookup, field = NULL, verbose = TRUE)

Arguments

layer

character (path to file) or an object of class "RasterLayer", "sf" or "SpatialPolygonsDataFrame". The spatial data corresponding to the network node as by argument node.

network

The Bayesian network. An object of class grain, or a character (the path to the .net file to be loaded)

node

character. The network node to be coupled with the file/object indicated by layer argument

intervals

A list of numeric vectors. For categorical variables the spatial data values associated to each state of the node, for continuous variables the boundary values dividing into the corresponding states, including upper and lower boundaries.

categorical

logical, or NULL. Is the node a categorical variable? If NULL the function will attempt to assign the logical value by looking at intervals argument.

field

character. Only for spatial vector data (e.g. shapefile), the field/column names in the attribute table corresponding to the nodes, ordered accordingly.

verbose

logical. If verbose = TRUE a summary of class boundaries and associated nodes and data will be printed to screen for checks.

spatial

logical. Should the output list include the input as raster or spatial vector? Default is TRUE, returning the list with an object of class "RasterLayer" or "sf" for each node associated. If FALSE, returns only the values.

spatialData

character with path to one or more raster files or to a single spatial vector file, or a list of objects of class 'RasterLayer' (for raster), or a single object of class 'sf' or 'SpatialPolygonsDataFrame' (for spatial vector). The spatial data associated to given network nodes, provided as file paths or as (list of) spatial objects. Items must be ordered accordingly to the corresponding nodes listed in lookup, or provided as named list, where names match exactly to the corresponding nodes name.

lookup

character (path to file) or a formatted list. This argument can be provided as path to a comma separated file or a formatted list (see setClasses )

Details

In future releases, this function may be rewritten to provide an S4/S3 object.

Value

linkNode returns a list of objects, including the spatial data and the related node information.
linkMultiple returns a list of lists. Each element of the list includes the spatial data and summary information for each of the input nodes.

See Also

dataDiscretize; setClasses

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Load data into global environment
list2env(ConwyData, environment())
lookup <- LUclasses

network <- LandUseChange
ln <- linkNode(layer=ConwyLU, network, node='CurrentLULC', intervals=c(2, 3, 1))
ln

## Link the Bayesian network to multiple spatial data at once, using a lookup list
spatialData <- c(ConwyLU, ConwySlope, ConwyStatus)
linkMultiple(spatialData, network, lookup, verbose = FALSE)

## Method for spatial vectorial data (i.e. class 'sf' or 'SpatialPolygon')
spatialData <- system.file("extdata", "Conwy.shp", package = "bnspatial")
lst <- linkMultiple(spatialData, network, lookup, field= c('LU', 'Slope', 'Status'))
lst

bnspatial documentation built on Jan. 17, 2020, 9:06 a.m.