surfacecentroid | R Documentation |
This function calculated 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,
w = NULL
)
## S4 method for signature 'data.frame'
surfacecentroid(x, ...)
## S4 method for signature 'SpatialPoints'
surfacecentroid(x, ...)
x |
( |
... |
Arguments passed to the |
output |
( |
center |
( |
radius |
( |
w |
( |
The function calculates the position of the centroid in 3D space (inside the sphere/Earth), which is then projected to the surface.
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.