Skip to contents

Averages the unit vectors, so a set straddling the antimeridian averages to the place it actually surrounds rather than to its numeric midpoint. There is no wrapping special case because there is no wrapping.

Usage

sphere_centroid(lon, lat, w = NULL)

Arguments

lon, lat

numeric degrees

w

optional weights

Value

c(lon, lat) in [-180, 180]

Examples

# either side of the dateline: the mean is ON the dateline, not at lon 0
round(sphere_centroid(c(170, -170), c(0, 0)))
#> [1] 180   0