Main Content


Mean location of geographic coordinates


[latmean,lonmean] = meanm(lat,lon)
[latmean,lonmean] = meanm(lat,lon,units)
[latmean,lonmean] = meanm(lat,lon,ellipsoid)


[latmean,lonmean] = meanm(lat,lon) returns row vectors of the geographic mean positions of the columns of the input latitude and longitude points.

[latmean,lonmean] = meanm(lat,lon,units) indicates the angular units of the data. The default angle unit is 'degrees'.

[latmean,lonmean] = meanm(lat,lon,ellipsoid) specifies the shape of the Earth using ellipsoid, which can be a referenceSphere, referenceEllipsoid, or oblateSpheroid object, or a vector of the form [semimajor_axis eccentricity]. The default ellipsoid model is a spherical Earth, which is sufficient for most applications.

If a single output argument is used, then geomeans = [latmean,longmean]. This is particularly useful if the original lat and lon inputs are column vectors.


Finding the mean position of geographic points is more complicated than simply averaging the latitudes and longitudes. meanm determines mean position through three-dimensional vector addition. See Geographic Statistics for Point Locations on a Sphere in the Mapping Toolbox User's Guide.


collapse all

Create some random latitudes.

lats = rand(3)
lats = 3×3

    0.8147    0.9134    0.2785
    0.9058    0.6324    0.5469
    0.1270    0.0975    0.9575

Create some random longitudes.

lons = rand(3)
lons = 3×3

    0.9649    0.9572    0.1419
    0.1576    0.4854    0.4218
    0.9706    0.8003    0.9157

Calculate the mean positions of the input geographic positions.

[latmean,lonmean] = meanm(lats,lons,'radians');

ans = 1×6

    0.6519    0.5581    0.6146    0.7587    0.7351    0.4250

See Also

| | | |