Skip to content

v.centerpoint

Calculate center points

v.centerpoint [-b] input=name [output=name] [type=string [,string,...]] [layer=string] [cats=range] [where=sql_query] [pcenter=string [,string,...]] [lcenter=string [,string,...]] [acenter=string [,string,...]] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.centerpoint input=name

grass.script.run_command("v.centerpoint", input, output=None, type="point,line,area", layer="1", cats=None, where=None, pcenter="mean", lcenter="mid", acenter="mean", flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("v.centerpoint", input="name")

Parameters

input=name [required]
    Name of input vector map
    Or data source for direct OGR access
output=name
    Name for output vector map
type=string [,string,...]
    Input feature type
    Allowed values: point, line, area
    Default: point,line,area
layer=string
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Default: 1
cats=range
    Category values
    Example: 1,3,7-9,13
where=sql_query
    WHERE conditions of SQL statement without 'where' keyword
    Example: income < 1000 and population >= 10000
pcenter=string [,string,...]
    point center
    Allowed values: mean, median, pmedian
    Default: mean
    mean: Center of gravity
    median: Geometric median (point of minimum distance)
    pmedian: Point closest to geometric median
lcenter=string [,string,...]
    line center
    Allowed values: mid, mean, median
    Default: mid
    mid: Line mid point
    mean: Center of gravity
    median: Geometric median (point of minimum distance) using line segments
acenter=string [,string,...]
    area center
    Allowed values: mean, median, bmedian
    Default: mean
    mean: Center of gravity
    median: Geometric median (point of minimum distance) using area sizes
    bmedian: Geometric median (point of minimum distance) using boundary segments
-b
    Do not build topology
    Advantageous when handling a large number of points
--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
    Name of input vector map
    Or data source for direct OGR access
    Used as: input, vector, name
output : str, optional
    Name for output vector map
    Used as: output, vector, name
type : str | list[str], optional
    Input feature type
    Allowed values: point, line, area
    Default: point,line,area
layer : str, optional
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Used as: input, layer
    Default: 1
cats : str, optional
    Category values
    Example: 1,3,7-9,13
    Used as: input, cats, range
where : str, optional
    WHERE conditions of SQL statement without 'where' keyword
    Example: income < 1000 and population >= 10000
    Used as: input, sql_query, sql_query
pcenter : str | list[str], optional
    point center
    Allowed values: mean, median, pmedian
    mean: Center of gravity
    median: Geometric median (point of minimum distance)
    pmedian: Point closest to geometric median
    Default: mean
lcenter : str | list[str], optional
    line center
    Allowed values: mid, mean, median
    mid: Line mid point
    mean: Center of gravity
    median: Geometric median (point of minimum distance) using line segments
    Default: mid
acenter : str | list[str], optional
    area center
    Allowed values: mean, median, bmedian
    mean: Center of gravity
    median: Geometric median (point of minimum distance) using area sizes
    bmedian: Geometric median (point of minimum distance) using boundary segments
    Default: mean
flags : str, optional
    Allowed values: b
    b
        Do not build topology
        Advantageous when handling a large number of points
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

v.centerpoint calculates center points for point clouds, lines and areas. Center points can be centers of gravity (coordinates' mean) or geometric medians (points of minimum distance, which is more robust in case of outliers.

For points, center points are calculated considering all points. For lines and areas, center points are calculated for each line or area separately.

If no output vector is given, center points are printed to stdout in ASCII point format:

<easting>|<northing>|<height>|<cat>

The category values are

  • 1 - mean of points
  • 2 - median of points
  • 3 - point closest to median of points
  • 4 - mid point of each line
  • 5 - mean of each line
  • 6 - median of each line
  • 7 - mean of each area
  • 8 - median of each area using area triangulation
  • 9 - median of each area using boundaries

If an output vector is given, categories of the respective lines and areas are transferred from the selected layer to layer 1. Layer 2 holds the same category values as for output to stdout.

Point centers

  • mean - center of gravity, mean of all point coordinates
  • median - geometric median, minimum distance to all points
  • pmedian - point closest to the geometric median

Line centers

  • mid - the mid point of each line, lies exactly on the line
  • mean - center of gravity, mean of all line segments, might not lie on the line
  • median - geometric median, minimum distance to all line segments, might not lie on the line

Area centers

  • mean - center of gravity, calculated using area triangulation
  • median - geometric median, minimum distance to area triangulation, might not lie inside the area
  • bmedian - geometric median, minimum distance to boundary segments, might not lie inside the area

EXAMPLE

Calculate center of gravity for the LiDAR point cloud 'elev_lid_bepts' in the North Carolina sample dataset:

v.centerpoint input=elev_lid_bepts output=elev_lid_bepts_mean
v.centerpoint in=urbanarea out=urbanarea_median acenter=median

SEE ALSO

v.centroids

AUTHOR

Markus Metz

SOURCE CODE

Available at: v.centerpoint source code (history)
Latest change: Friday Feb 21 10:10:05 2025 in commit 7d78fe3