Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_centroids

get_centroids


Description

Centroid of patches

Usage

get_centroids(landscape, directions, cell_center, return_sp, verbose)

## S3 method for class 'RasterLayer'
get_centroids(
  landscape,
  directions = 8,
  cell_center = FALSE,
  return_sp = FALSE,
  verbose = TRUE
)

## S3 method for class 'RasterStack'
get_centroids(
  landscape,
  directions = 8,
  cell_center = FALSE,
  return_sp = FALSE,
  verbose = TRUE
)

## S3 method for class 'RasterBrick'
get_centroids(
  landscape,
  directions = 8,
  cell_center = FALSE,
  return_sp = FALSE,
  verbose = TRUE
)

## S3 method for class 'stars'
get_centroids(
  landscape,
  directions = 8,
  cell_center = FALSE,
  return_sp = FALSE,
  verbose = TRUE
)

## S3 method for class 'list'
get_centroids(
  landscape,
  directions = 8,
  cell_center = FALSE,
  return_sp = FALSE,
  verbose = TRUE
)

Arguments

landscape

Raster* Layer, Stack, Brick, SpatRaster (terra), stars, or a list of rasterLayers.

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_sp

If true, a SpatialPointsDataFrame is returned.

verbose

Print warning messages

Details

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.

Examples

# get centroid location
get_centroids(landscape)

landscapemetrics

Landscape Metrics for Categorical Map Patterns

v1.5.2
GPL-3
Authors
Maximillian H.K. Hesselbarth [aut, cre] (<https://orcid.org/0000-0003-1125-9918>), Marco Sciaini [aut] (<https://orcid.org/0000-0002-3042-5435>), Jakub Nowosad [aut] (<https://orcid.org/0000-0002-1057-3721>), Sebastian Hanss [aut] (<https://orcid.org/0000-0002-3990-4897>), Laura J. Graham [ctb] (Input on package structure), Jeffrey Hollister [ctb] (Input on package structure), Kimberly A. With [ctb] (Input on package structure), Florian Privé [ctb] (Original author of underlying C++ code for get_nearestneighbour() function), Project Nayuki [ctb] (Original author of underlying C++ code for get_circumscribingcircle and lsm_p_circle), Matt Strimas-Mackey [ctb] (Bugfix in sample_metrics())
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.