Skip to content

r.centroids

Creates vector map of centroids from raster of "clumps".

r.centroids input=name output=name [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.centroids input=name output=name

grass.script.run_command("r.centroids", input, output, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("r.centroids", input="name", output="name")

Parameters

input=name [required]
    Raster map of clumps, clusters of same-valued pixels
output=name [required]
    Name for output vector map
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str, required
    Raster map of clumps, clusters of same-valued pixels
    Used as: input, raster, name
output : str, required
    Name for output vector map
    Used as: output, vector, name
overwrite: bool, optional
    Allow output files to overwrite existing files
    Default: False
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

r.centroids is a wrapper function for r.volume that computes the center point of raster clumps of data (neighboring, same-valued pixels). The centroids will always fall within the clump so they may not be the true, mathematical centroid. The centroids will always fall at the center of a pixel.

r.centroids requires an input raster containing clumps of data such as the output of r.clump.

EXAMPLES

Find the centroids of the basins map (North Carolina sample dataset). First, set computational area.

g.region raster=basin_50K

Then, compute the centroids.

r.centroids input=basin_50K output=centroids50K

image-alt

SEE ALSO

r.volume r.clump

AUTHOR

Caitlin Haedrich, Center for Geospatial Analytics, North Carolina State University, January, 2021.

SOURCE CODE

Available at: r.centroids source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819