Learn R Programming

terra (version 1.5-34)

centroids: Centroids

Description

Get the centroids of polygons or lines, or centroid-like points that are guaranteed to be inside the polygons or on the lines.

Usage

# S4 method for SpatVector
centroids(x, inside=FALSE)

Arguments

x

SpatVector

inside

logical. If TRUE the points returned are not the true centroids, but they are guaranteed to be inside the polygons or on the lines. True centroids may be outside a polygon (e.g. when a polygon is "bean shaped", and are unlikely to be on their line

Value

SpatVector of points

Examples

Run this code
# NOT RUN {
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
x <- centroids(v)
y <- centroids(v, TRUE)
# }

Run the code above in your browser using DataLab