raster2Graph | R Documentation |
Create a graph from an raster according the connection between cells
raster2Graph(r, cellsize = NULL, relative.distance = TRUE, silent = TRUE)
r |
An object of stars or RasterLayer. The value of each cell of the raster is the ‘smoothness’ to indicate how easy the cell connecting with neighbor cells. |
cellsize |
Numeric. Re-sample the input raster to given resolution and use the re-sampled raster to build graph. Set this to NULL if using the original resolution of of the input raster. |
relative.distance |
Boolean. If fasle, absolute distance between cells is used to compute the edge weight; otherwise, relative distance between cells is used. Default is true |
silent |
Boolean. A logical indicating if some “progress report” should be given. Default is TRUE. |
a list with an graph and the re-sampled raster (a object of stars). The graph is igraph object, with cells as node and connections as weight.
# read in habitat suitability data of wolf in Europe library(stars) hsi.file = system.file("extdata","wolf3_int.tif",package="habCluster") wolf = read_stars(hsi.file) # build graph from raster g = raster2Graph(wolf, 40000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.