mapTarget: Make maps for target node

Description Usage Arguments Details Value See Also Examples

View source: R/mapTarget.R

Description

This function creates the required spatial outputs for the target node.

Usage

1
2
3
mapTarget(target, statesProb, what = c("class", "entropy"), msk,
  midvals = NULL, targetState = colnames(statesProb), spatial = TRUE,
  exportRaster = FALSE, path = getwd())

Arguments

target

character. The node of interest to be modelled and mapped.

statesProb

matrix. The probability matrix as returned by queryNet and queryNetParallel. Named columns required, accordingly to states. Columns are the target node states and rows each location considered from the area of interest.

what

character. The required output, one or more of these values are valid:

  • "class" returns the relatively most likely states.

  • "entropy" calculates the Shannon index and returns the entropy given the state probabilities.

  • "probability" returns an object for each state of the target node, with associated probability.

  • "expected" gives the expected value for the target node (see Details). Only valid for continuous target nodes. midValues argument must be provided.

  • "variation" returns the coefficient of variation, as a measure of uncertainty.

msk

an object of class "RasterLayer". The reference raster to be used as mask. All model outputs will have the same resolution and same extent as this raster. All locations with no data (i.e. NA) cells in this raster will be ignored as well.

midvals

vector of length equal to the number of states of the target node. Applies only if the target node is a continuous variable, in which case midvals must contain the mid values for each of the intervals

targetState

character. One or more states of interest from the target node. Applies only when argument what includes 'probability'. Default is set to all states of the node.

spatial

logical. Should the output be spatially explicit -i.e. a georeferenced raster? Default is TRUE, returning an object of class "RasterLayer". If FALSE, returns a data.frame with one row for each non NA cell in msk raster and in columns the output required by mask argument.

exportRaster

Logical or character. Should the spatial output be exported to a raster file? Applies only if argument spatial=TRUE. When exportRaster=TRUE, rasters will be exported in .tif format. A character specifying another extension can be provided, in which case the raster will be exported in that format. Only formats listed by writeFormats are valid.

path

The directory to store the output files, when exportRaster is not FALSE. Default is the working directory (getwd()). File names are set by a default naming convention, see Details.

Details

mapTarget

The expected value is calculated by summing the mid values of target node states weighted by their probability: p1 * midVal_1 + p2 * midval_2 + ... + pn * midval_n
When a RasterLayer is exported to a file, the file name is set by default, accordingly to the following naming convention:

An additional comma separated file (.csv) is written to the same directory when "class", providing a key to interpret the raster values and the state they refer to.

Value

A list of objects, one for each item required in what argument. If spatial = TRUE a list of rasters of class "RasterLayer" are returned, if FALSE a list of vectors with values associated to each non NA cell in msk raster (i.e. the vectorised raster). If argument exportRaster is specified, outputs are exported to files to the directory specified in path.

See Also

bnspatial, aoi, queryNet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data(ConwyData)
list2env(ConwyData, environment())

network <- LandUseChange
target <- 'FinalLULC'
statesProb <- queryNet(network, target, evidence)

maps <- mapTarget(target, statesProb, msk=ConwyLU)

library(raster)
plot(maps$Class)
plot(maps$Entropy)

## Returns required outputs by coordinates for each 'msk' cell in a data frame:
noMap <- mapTarget(target, statesProb, msk=ConwyLU, spatial=FALSE)
head(noMap)

## Create a probability surface for the "forest" state of target node "FinalLULC"
mp <- mapTarget('FinalLULC', statesProb, what='probability', targetState='forest', msk=ConwyLU)
plot(mp$Probability$forest)

bnspatial documentation built on Nov. 18, 2017, 4:13 a.m.