rCentroid: Determine the centroid of patches in a raster

Description Usage Arguments Value See Also Examples

Description

The centroid is the average location of all cells of a foreground patch.

Usage

1
rCentroid(obj, output = "raster", background = NULL)

Arguments

obj

[RasterLayer(1)]
The object to modify.

output

[character(1)]
the type in which the output should be returned. Either "raster" (default) or "geom".

background

[integerish(1)]
the value any cell with value NA should have.

Value

Depending on output, either

  1. a RasterLayer of the same dimension as obj, in which the centroid of each foreground patch has the value of the patch-number identified with rPatches and where the remaining cells of each foreground patch have the value NA or

  2. a geometry object of the centroids.

See Also

Other operators to determine objects: rPatches, rSkeletonise

Examples

1
2
3
4
5
6
7
input <- rtRasters$continuous
patches <- rPatches(rBinarise(input, thresh = 30))
visualise(rCentroid(patches))

# get centroid coordinates
centroid_coords <- rCentroid(patches, output = "geom")
visualise(raster = patches, geom = centroid_coords, linecol = "red")

EhrmannS/rasterTools documentation built on May 28, 2019, 8:24 a.m.