centroid.owin

0th

Percentile

Centroid of a window

Computes the centroid (centre of mass) of a window

Keywords
spatial, math
Usage
centroid.owin(w)
w
A window
Details

The centroid of the window w is computed. The centroid (centre of mass'') is the point whose $x$ and $y$ coordinates are the mean values of the $x$ and $y$ coordinates of all points in the window.

The argument w should be a window (an object of class "owin", see owin.object for details) or can be given in any format acceptable to as.owin().

The calculation uses an exact analytic formula for the case of polygonal windows.

Note that the centroid of a window is not necessarily inside the window. If the window is convex then it does contain its centroid.

Value

• A list with components x, y giving the coordinates of the centroid of the window w.

owin, as.owin

Aliases
• centroid.owin
Examples
w <- owin(c(0,1),c(0,1))
centroid.owin(w)
# returns 0.5, 0.5

data(demopat)
w <- demopat\$window
# an irregular window
plot(w)
# plot the window
points(centroid.owin(w))
# mark its centroid

# pixel approximation of window
points(centroid.owin(wapprox))
# should be indistinguishable
<testonly>centroid.owin(w)
centroid.owin(wapprox)</testonly>
Documentation reproduced from package spatstat, version 1.19-2, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.