View source: R/sl.barycenter.R
sl.barycenter | R Documentation |
Compute the barycenter of points on a unit sphere. The locations of the points can be provided in x-y-z or lon-lat coordinates. Can be used directly to compute the barycenter (centroid) of a triangle using its vertices, but NOT FOR POLYGONS WITH MORE THAN 3 VERTICES! To that end, use sl.centroid
.
sl.barycenter(x = NULL, y = NULL, z = NULL, lon = NULL, lat = NULL, weights = NULL, rm.na = TRUE)
x |
a vector of arbitrary length with the x-coordinates of the points on the unit sphere. If specified, |
y |
a vector of the same length as |
z |
a vector of the same length as |
lon |
a vector of arbitrary length with the longitudes of the points. Used only if |
lat |
a vector of the same length as |
weights |
a vector of the length corresponding to the number of points with optional weights of the points. |
rm.na |
a logical values specifying whether or not to remove NAs. Default is |
The computation is based on the x-y-z locations of the points. The directly resulting barycenter is located within the unit sphere and projected from the origin back onto the unit sphere.
lon |
longitude of the barycenter |
lat |
latitude of the barycenter |
Helge Goessling
sl.centroid
## Using x-y-z as input:
sl.barycenter(x=c(1,0,0),y=c(0,1,0),z=c(0,0,1))
## Using lon-lat as input:
sl.barycenter(lon=c(0,90,0),lat=c(0,0,90))
## Both should return:
## $lon
## [1] 45
##
## $lat
## [1] 35.26439
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.