graphab_habitat: Create a habitat type in a Graphab project

View source: R/graphab_habitat.R

graphab_habitatR Documentation

Create a habitat type in a Graphab project

Description

The function creates a new habitat in the Graphab project in two possible ways:

  • From the raster file defining the project, based on a code value.

  • From an external vector file (polygon or point type). NOT YET

Usage

graphab_habitat(
  proj_name,
  name,
  type = "raster",
  rast_codes = NULL,
  vec_layer = NULL,
  vec_capa_field = NULL,
  minarea = 0,
  maxsize = NULL,
  con8 = FALSE,
  parallel.java = NULL,
  alloc_ram = NULL,
  proj_path = NULL
)

Arguments

proj_name

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

name

A character string specifying the name (arbitrary) of the new habitat type in the raster project.

type

A character string specifying whether the new habitat type is defined from the raster layer defining the project ('type="raster"', default) or from an external vector layer ('type="vector"') of type polygon or point.

rast_codes

(default=NULL) If 'type="raster"', code value(s) on the categorical raster layer defining the project corresponding to the type of habitat. Must be an integer or a vector of integer values.

vec_layer

A character string indicating the path (absolute or relative) to a vector layer in shapefile (.shp) or geopackage (.gpkg) format.

vec_capa_field

(default=NULL) If 'type="vector"', name of the column of the vector layer attribute table setting the capacity of each habitat patch.

minarea

(optional, default=0) An integer or numeric value specifiying the minimum area in hectares for a habitat patch size to become a graph node.

maxsize

(optional, default=NULL, only if 'type="raster"'). An integer or numeric value specifying the maximum side length of the rectangular full extent of each habitat patch in metric units. If this side length exceeds maxsize m, then several patches are created.

con8

(optional, default=FALSE) A logical indicating whether a neighborhood of 8 pixels (TRUE) is used for patch definition. By default, con8=4, corresponding to 4 pixel neighborhood.

parallel.java

An integer indicating how many computer cores are used to run the .jar file. By default, parallel.java = NULL, and java sets it according to local settings.

alloc_ram

(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.

proj_path

(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().

Details

A habitat patch consists of the central pixel with its eight neighbors if they are of the same value (8-connexity) and the path geometry is not simplified. See more information in Graphab 3.0 manual: https://thema.umlp.fr/productions/software/graphab/download/manual-3.0-en.pdf

Author(s)

P. Savary, T. Rudolph

References

\insertRef

foltete2012softwaregraph4lg \insertReffoltete2021graphabgraph4lg \insertRefsavary2024multiplegraph4lg

Examples

## Not run: 
proj_name <- "graphab_example"
graphab_habitat(proj_name = proj_name,
               name = "forest",
               type = "raster",
               rast_codes = c(1,2))

## End(Not run)

graph4lg documentation built on Sept. 24, 2026, 5:12 p.m.