View source: R/get_centroids.R
get_centroids | R Documentation |
Centroid of patches
get_centroids(
landscape,
directions = 8,
cell_center = FALSE,
return_vec = FALSE,
verbose = TRUE
)
landscape |
A categorical raster object: SpatRaster; Raster* Layer, Stack, Brick; stars or a list of SpatRasters. |
directions |
The number of directions in which patches should be connected: 4 (rook's case) or 8 (queen's case). |
cell_center |
If true, the coordinates of the centroid are forced to be a cell center within the patch. |
return_vec |
If true, a sf object is returned. |
verbose |
Print warning messages |
Get the coordinates of the centroid of each patch. The centroid is by default
defined as the mean location of all cell centers. To force the centroid to be
located within each patch, use the cell_center
argument. In this case, the
centroid is defined as the cell center that is the closest to the mean location.
# get centroid location
landscape <- terra::rast(landscapemetrics::landscape)
get_centroids(landscape)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.