# NOT RUN {
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
# }
# NOT RUN {
wapprox <- as.mask(w)
# pixel approximation of window
# }
# NOT RUN {
points(centroid.owin(wapprox))
# should be indistinguishable
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab