Description Usage Arguments Details Value See Also Examples
This function creates the required spatial outputs for the target node.
| 1 2 3 4 5 6 7 8 9 10 11 12 | 
| target | character. The node of interest to be modelled and mapped. | 
| statesProb | matrix. The probability matrix as returned by  | 
| what | character. The required output, one or more of these are valid: 
 | 
| msk | an object of class "RasterLayer" (raster) or a spatial vector of class "sf" (vector spatial polygons). The reference spatial boundaries to be used as mask. All model outputs will have the same extent/outline as this object. All locations with no data (i.e. NA) will be ignored. | 
| 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  | 
| targetState | character. One or more states of interest from the target node. Applies only 
when argument  | 
| spatial | logical. Should the output be spatially explicit -i.e. a georeferenced raster or spatial vector? 
Default is TRUE, returning an object of class "RasterLayer" or "sf" for polygons. If FALSE, returns a data frame 
with one row for each valid cell/feature from  | 
| export | Logical or character. Should the spatial output be exported to file? 
Applies only if argument  | 
| path | The directory to store the output files, when  | 
| exportRaster | deprecated, use  | 
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 exporting to a file, the file name is set by default, according to the following naming convention:
"class" <target node name>_Class.<file format  -default .tif>
"entropy" <target node name>_ShanEntropy.<file format  -default .tif>
"probability" <target node name>_Probability_.<targetState>.<file format  -default .tif>
"expected" <target node name>_ExpectedValue.<file format  -default .tif>
"variation" <target node name>_CoefVariation.<file format  -default .tif>
An additional comma separated file (.csv) is written to the same directory when "class", 
providing a key to interpret the values and the state they refer to.
A list of objects, one for each item required in what argument. If spatial = TRUE 
a list of rasters of class "RasterLayer" are returned, or a single spatial vector of class "sf" with one column 
for each output requested. If FALSE, for raster data it returns a list of vectors with the values 
associated to each non NA cell in msk raster (i.e. the vectorised raster). For vector data it returns a data frame. 
If argument export is specified, outputs are exported to files to the directory specified in path.
| 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 | 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)
## With spatial vector (totally made up data here, just for demo):
library(sf)
spVector <- st_read(system.file("extdata", "Conwy.shp", package = "bnspatial"))
ev <- evidence[1:nrow(spVector), ]
probs <- queryNet(network, 'FinalLULC', ev)
mp <- mapTarget('FinalLULC', statesProb=probs,
                what=c('entropy', 'probability'), targetState='forest', msk=spVector)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.