MK_BCentrality: Betweenness Centrality metrics using Conefor command line

View source: R/MK_BCentrality.R

MK_BCentralityR Documentation

Betweenness Centrality metrics using Conefor command line

Description

Use this function to calculate the BC, BCIIC and BCPC indexes under one or several distance thresholds using Conefor command line.

Usage

MK_BCentrality(
  nodes,
  id,
  attribute = NULL,
  area_unit = "ha",
  distance = list(type = "centroid", resistance = NULL),
  metric = c("BC", "BCIIC", "BCPC"),
  distance_thresholds = NULL,
  probability = NULL,
  LA = NULL,
  coneforpath = NULL,
  dA = FALSE,
  dvars = FALSE,
  parallel = NULL,
  rasterparallel = FALSE,
  write = NULL,
  intern = TRUE
)

Arguments

nodes

Object containing nodes (e.g., habitat patches or fragments) information. It can be of the following classes:
- Data.frame with at least two columns: the first for node IDs and the second for attributes.
- Spatial data of type vector (class sf, SpatVector, SpatialPolygonsDataFrame). It must be in a projected coordinate system.
- Raster (class RasterLayer, SpatRaster). It must be in a projected coordinate system. The values must be integers representing the ID of each habitat patch or node, with non-habitat areas represented by NA values (see clump or patches).

id

character. If nodes is a vector then you can specify the column name with the node ID. If NULL, then a new id will be generated.

attribute

character or vector. If NULL the area of the nodes will be used as the node attribute. The unit of area can be selected using the area_unit parameter. To use an alternative attribute, consider the class type of the object in the nodes parameter:
- If nodes is a spatial vector or data.frame, specify the name of the column containing the attribute for the nodes.
- If nodes is a raster layer then it must be a numeric vector with the node's attribute. The length of the vector must be equal to the number of nodes.

area_unit

character. (optional, default = "m2")
. A character indicating the area units when attribute is NULL. Some options are "m2" (the default), "km2", "cm2", or "ha"; See unit_convert for details.

distance

A matrix or list to establish the distance between each pair of nodes. Distance between nodes may be Euclidean distances (straight-line distance) or effective distances (cost distances) by considering the landscape resistance to the species movements. If it is a matrix, then the number of columns and rows must be equal to the number of nodes. This distance matrix could be generated by the distancefile function. If it is a list, then it must contain the distance parameters necessary to calculate the distance between nodes. For example: “type” and “resistance”. For "type" choose one of the distances: "centroid" (faster), "edge", "least-cost" or "commute-time". If the type is equal to "least-cost" or "commute-time", then you must use the "resistance" argument. To see more arguments see the distancefile function.

metric

A character indicating the Betweenness Centrality metric to use: "BC" (the classical), “BCIIC” considering binary indices and topological distances, and “BCPC” (recommended) considering the maximum product probabilities.

distance_thresholds

A numeric indicating the dispersal distance or distances (meters) of the considered species. If NULL then distance is estimated as the median dispersal distance between nodes. Alternatively, the dispersal_distance function can be used to estimate the dispersal distance using the species home range.

probability

A numeric value indicating the probability that corresponds to the distance specified in the distance_threshold. For example, if the distance_threshold is a median dispersal distance, use a probability of 0.5 (50%). If the distance_threshold is a maximum dispersal distance, set a probability of 0.05 (5%) or 0.01 (1%). Use in case of selecting the "BCPC" metric. If probability = NULL, then a probability of 0.5 will be used.

LA

numeric. (optional, default = NULL). The maximum landscape attribute, which is the attribute value that would correspond to a hypothetical habitat patch covering all the landscape with the best possible habitat, in which IIC and PC would be equal to 1. For example, if nodes attribute corresponds to the node area, then LA equals total landscape area. If nodes attribute correspond to a quality-weighted area and the quality factor ranges from 0 to 100, LA will be equal to 100 multiplied by total landscape area. The value of LA does not affect at all the importance of the nodes and is only used to calculate the overall landscape connectivity. If no LA value is entered (default) and overall = TRUE or onlyoverall = TRUE, the function will only calculate the numerator of the global connectivity indices and the equivalent connected ECA or EC index.

coneforpath

character. Path to Conefor 2.6 with command line interface (http://www.conefor.org/coneforsensinode.html). Example, "C:/Users/coneforWin64.exe".

dA

logical. If TRUE, then the delta attribute will be added to the node's importance result.

dvars

logical. If TRUE, then the absolute variation will be added to the node's importance result.

parallel

(optional, default = NULL). A numeric specifying the number of cores to parallelize the index estimation of the PC or IIC index and its deltas.Particularly useful when you have more than 1000 nodes. By default the analyses are not parallelized.

rasterparallel

logical. If parallel is FALSE and nodes is a raster then you can use this argument to assign the metrics values to the nodes raster. It is useful when raster resolution is less than 100 m2.

write

character. Write output shapefile, example, "C:/ejemplo.shp".

intern

logical. Show the progress of the process, default = TRUE. Sometimes the advance process does not reach 100 percent when operations are carried out very quickly.

Details

To use this function you need to download and uncompress Conefor 2.6 with command line interface from http://www.conefor.org/coneforsensinode.html
Betweenness Centrality metrics can be calculated in three different ways:
- BC calculates the classical Betweenness Centrality metric as originally defined by Freeman (1977; Sociometry 40: 35–41).
- BCIIC and BCPC calculate the improved version of the BC metric by Bodin and Saura (2010) integrated within the same analytical framework as the IIC (binary) and the PC (probabilistic) metrics.

References

Saura, S. and Torne, J. (2012). Conefor 2.6. Universidad Politecnica de Madrid. Available at www.conefor.org.
Freeman L.C. (1977). Set of Measures of Centrality Based on Betweenness. Sociometry 40: 35-41.
Bodin, O. and Saura, S. (2010). Ranking individual habitat patches as connectivity providers: integrating network analysis and patch removal experiments. Ecological Modelling 221: 2393-2405.

Examples

## Not run: 
library(Makurhini)
data("habitat_nodes", package = "Makurhini")
nrow(habitat_nodes) #Number of nodes

#Two distance thresholds.
#You need to place your path to the conefor .exe
BCIIC <- MK_BCentrality(nodes = habitat_nodes, id = "Id",
            coneforpath = "C:/Users/coneforWin64.exe",
            distance = list(type = "centroid"),
            metric = "BCIIC", LA = NULL,
            distance_thresholds = c(10000, 30000)) #10 and 30 km

#Using raster
data("habitat_nodes_raster", package = "Makurhini")
##Using parallel
BCPC_parallel <- MK_BCentrality(nodes = habitat_nodes_raster,
                    coneforpath = "C:/Users//coneforWin64.exe",
                    id = "id", attribute = NULL,
                    distance = list(type = "centroid"),
                    metric = "BCPC", LA = NULL, probability = 0.5,
                    distance_thresholds = 40000,
                    parallel = 4) #40 and 60 km

## End(Not run)

OscarGOGO/Makurhini documentation built on Jan. 9, 2025, 1:20 p.m.