surfacecentroid | R Documentation |
This function the projected place of the centroid from a pointset on the sphere.
surfacecentroid(x, ...)
## S4 method for signature 'matrix'
surfacecentroid(x, output = "polar", center = c(0, 0, 0), radius = authRadius)
## S4 method for signature 'data.frame'
surfacecentroid(x, ...)
## S4 method for signature 'SpatialPoints'
surfacecentroid(x, ...)
x |
( |
... |
Arguments passed to the |
output |
( |
center |
( |
radius |
( |
The function implements great circle calculations to infer on the place of the centroid, which makes it resource demanding. This is necessary to avoid a particual error that frequently occurrs with other methods for centroid calculation, namely that the place of the centroid is right, but on the opposite hemisphere.
Either an XYZ or a long-lat numeric
vector.
# generate some random points
allData <- rpsphere(1000)
# select only a subset
points<-allData[allData[,3]>1500,]
# transform to 2d
points2 <- CarToPol(points, norad=TRUE)
# the spherical centroid
sc <- surfacecentroid(points2, output="polar")
sc
#3d plot
plot(points2, xlim=c(-180, 180), ylim=c(-90, 90))
points(sc[1], sc[2], col="red", cex=5, pch=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.