Learn R Programming

graph4lg (version 2.0.0)

graphab_to_igraph: Create landscape graphs from Graphab link set

Description

The function creates a landscape graph from a link set and a set of habitat patches created with Graphab and converts it into a graph object of class igraph. The graph has weighted links and is undirected. Nodes attributes present in the habitat layer created with Graphab project are included, including connectivity metrics when computed.

Usage

graphab_to_igraph(
  proj_name,
  linkset,
  habitat,
  nodes = NULL,
  weight = "cost",
  proj_path = NULL,
  fig = FALSE,
  crds = FALSE
)

Value

A graph object of class igraph (if crds = FALSE) or a list of objects: a graph object of class igraph and a data.frame with the nodes spatial coordinates (if crds = TRUE).

Arguments

proj_name

A character string indicating the project name. It is also the name of the directory in which proj_name.xml file is found. By default, 'proj_name' is searched into the current working directory

linkset

A character string indicating the name of the linkset used to create the graph links. The linkset must have been created previously (see the function graphab_link). It can be complete or planar. The graph is given the topology of the selected link set.

habitat

A character string indicating the name of a habitat type created in the Graphab project.

nodes

Deprecated parameter from graph4lg < 2.0.

weight

A character string ("euclid" or "cost") indicating whether to weight the links with Euclidean distance or cost-distance (default) values.

proj_path

(optional) A character string indicating the path to the directory that contains the project directory ('proj_name'). By default, 'proj_name' is searched into the current working directory

fig

Logical (default = FALSE) indicating whether to plot a figure of the resulting spatial graph. The figure is plotted using function plot_graph_lg. The plotting can be long if the graph has many nodes and links.

crds

Logical (default = FALSE) indicating whether to create an object of class data.frame with the node centroid spatial coordinates. Such a data.frame has 3 columns: 'ID', 'x', 'y'.

Author

P. Savary

References

foltete2012softwaregraph4lg

Examples

Run this code
if (FALSE) {
proj_path <- system.file('extdata', package = 'graph4lg')
proj_name <- "graphab_example"
linkset <- "forest_link_planar"
habitat <- "forest"
graph <- graphab_to_igraph(proj_name = proj_name,
                           linkset = linkset,
                           habitat = habitat,
                           weights = "cost",
                           proj_path = proj_path,
                           crds = FALSE,
                           fig = FALSE)
                           }

Run the code above in your browser using DataLab