cgmedn
Median centre of points
cgmedn(x, y = NULL, lonlat = FALSE)The median of the x coordinates and the median of the y
coordinates (the mean of the two middle values for an even number of
points). It depends on the orientation of the axes: rotating the points
does not rotate it. webpt() gives the rotation-invariant centre of
minimum distance.
Parameters
Section titled “Parameters”x, yThe points:
xandynumeric vectors of equal length; orxa matrix or data frame with columns namedxandy(orXandY, assf::st_coordinates()names them, orlonandlatwithlonlat = TRUE) andyNULL; orxan sf or sfc object of POINT geometries, whose coordinate reference system must agree withlonlat. An unnamed two-column matrix is read asxtheny; other columns are never taken by position. Vectors given separately (x,y, andwortwhere a function takes them) are matched by name when every one is named and no name repeats, as elsewhere in the package; otherwise by position. No missing or infinite values.lonlatFALSE(the default) whenxandyare planar coordinates in one length unit;TRUEwhen they are longitude and latitude in degrees, which are then projected to metres byeqproj()about their own centre, and centres are returned in degrees. It is never guessed.
Returns
Section titled “Returns”A named numeric vector c(x, y), in degrees when
lonlat = TRUE (the medians are taken of the projected coordinates).
References
Section titled “References”Neft, D. S. (1966). Statistical Analysis for Areal Distributions. Regional Science Research Institute, Philadelphia.
Examples
Section titled “Examples”cgmedn(c(1, 2, 3, 10), c(5, 1, 2, 2))Generated from the R help page: cgmedn in the R reference.