patch_config: Calculate interpatch distances and areas

View source: R/patch-config.r

patch_configR Documentation

Calculate interpatch distances and areas

Description

Given a set of patches in raster or vector format, calculate the areas and interpatch distances.

Usage

patch_config(x, units = c("m", "km"))

Arguments

x

patch network in raster or vector format, see Details.

units

character; whether distances and areas should be in meters or kilometers.

Details

If the patch network is provided as a Raster object, cells included in the network should be 1, and background cells should be 0 or NA. Patches can also be provided as polygons from either the sf or sp packages. Spatial data must be provided in projected coordinates with units of meters.

Value

A patch_config object with two elements: the interpatch distances (distances) and patch areas (areas).

Examples

# raster
r <- raster::raster(nrows = 10, ncols = 10, crs = "+proj=laea")
r[] <- round(runif(raster::ncell(r)) * 0.7)
patch_config(r, units = "m")

# polygon
p_poly <- raster::rasterToPolygons(r, dissolve = TRUE)
p_poly <- sf::st_as_sf(p_poly)
p_poly <- p_poly[p_poly$layer == 1, ]
p_poly <- sf::st_cast(p_poly, "POLYGON")
patch_config(p_poly, units = "km")

mstrimas/metacapa documentation built on Feb. 22, 2025, 3:23 a.m.