w <- owin(c(0,1),c(0,1))
centroid.owin(w)
# returns 0.5, 0.5
data(demopat)
w <- Window(demopat)
# an irregular window
cent <- centroid.owin(w, as.ppp = TRUE)
## Not run:
# plot(cent)
# # plot the window and its centroid
# ## End(Not run)
wapprox <- as.mask(w)
# pixel approximation of window
## Not run:
# points(centroid.owin(wapprox))
# # should be indistinguishable
# ## End(Not run)
Run the code above in your browser using DataLab