graphab_link: Create a link set in the Graphab project

View source: R/graphab_link.R

graphab_linkR Documentation

Create a link set in the Graphab project


The function creates a link set between habitat patches in the Graphab project.


  distance = "cost",
  cost = NULL,
  topo = "planar",
  remcrosspath = FALSE,
  proj_path = NULL,
  alloc_ram = NULL



A character string indicating the Graphab project name. The project name is also the name of the project directory in which the file proj_name.xml is. It can be created with graphab_project


A character string indicating whether links between patches are computed based on:

  • Shortest cost distances: distance='cost' (default)

  • Straight Euclidean distances: distance='euclid'

In the resulting link set, each link will be associated with its corresponding cost-distance and the length of the least-cost path in meters (if distance='cost') or with its length in Euclidean distance (if distance='euclid')


A character string indicating the name of the created linkset.


This argument could be:

  • A data.frame indicating the cost values associated to each raster cell value. These values refer to the raster used to create the project with graphab_project. The data.frame must have two columns:

    • 'code': raster cell values

    • 'cost': corresponding cost values

  • The path to an external raster file in .tif format with cost values.


A character string indicating the topology of the created link set. It can be:

  • Planar (topo='planar' (default)): a planar set of links is created. It speeds up the computation but will prevent from creating complete graphs with graphab_graph.

  • Complete (topo='complete'): a complete set of links is created. A link is computed between every pair of patches.


(optional, default = FALSE) A logical indicating whether links crossing patches are removed (TRUE).


(optional) A character string indicating the path to the directory that contains the project directory. It should be used when the project directory is not in the current working directory. Default is NULL. When 'proj_path = NULL', the project directory is equal to getwd().


(optional, default = NULL) Integer or numeric value indicating RAM gigabytes allocated to the java process. Increasing this value can speed up the computations. Too large values may not be compatible with your machine settings.


By default, links crossing patches are not ignored nor broken into two links. For example, a link from patches A to C crossing patch B is created. It takes into account the distance inside patch B. It can be a problem when computing BC index. See more information in Graphab 2.8 manual:


P. Savary, T. Rudolph


## Not run: 
df_cost <- data.frame(code = 1:5,
                      cost = c(1, 10, 100, 1000, 1))
graphab_link(proj_name = "grphb_ex",
            distance = "cost",
            name = "lcp",
            cost = df_cost,
            topo = "complete")

## End(Not run)

graph4lg documentation built on Feb. 16, 2023, 5:43 p.m.