Main Content

ecef2geodetic

Transform geocentric Earth-centered Earth-fixed coordinates to geodetic

Description

[lat,lon,h] = ecef2geodetic(spheroid,X,Y,Z) transforms the geocentric Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates specified by X, Y, and Z to the geodetic coordinates specified by lat, lon, and h. Specify spheroid as the reference spheroid for the geodetic coordinates.

example

[lat,lon,h] = ecef2geodetic(___,angleUnit) specifies the units for latitude and longitude. Specify angleUnit as 'degrees' (the default) or 'radians'.

[lat,lon,h] = ecef2geodetic(X,Y,Z,spheroid) is supported but not recommended. Unlike the previous syntaxes, this syntax returns lat and lon in radians. Specify spheroid as either a reference spheroid or an ellipsoid vector of the form [semimajor_axis, eccentricity]. Specify X, Y, and Z in the same units as the length unit of the spheroid argument. Additionally, the output h returns in the same units as the length unit of the spheroid argument.

Examples

collapse all

Find the geodetic coordinates of Paris, France, using its ECEF coordinates.

First, specify the reference spheroid as WGS84 with length units measured in kilometers. For more information about WGS84, see Comparison of Reference Spheroids. The units for the ECEF coordinates and ellipsoidal height must match the units specified by the LengthUnit property of the reference spheroid.

wgs84 = wgs84Ellipsoid('kilometer');

Specify the ECEF coordinates of Paris in kilometers.

x = 4201;
y = 172.46;
z = 4780.1;

Then, calculate the geodetic coordinates of Paris. The result h is ellipsoidal height in kilometers.

[lat,lon,h] = ecef2geodetic(wgs84,x,y,z)
lat = 
48.8562
lon = 
2.3508
h = 
0.0674

Reverse the transformation using the geodetic2ecef function. In this example, x and z display in scientific notation.

[x,y,z] = geodetic2ecef(wgs84,lat,lon,h)
x = 
4.2010e+03
y = 
172.4600
z = 
4.7801e+03

Input Arguments

collapse all

Reference spheroid, specified as a referenceEllipsoid object, oblateSpheroid object, or referenceSphere object. The term reference spheroid is used synonymously with reference ellipsoid. To create a reference spheroid, use the creation function for the object. To specify the reference ellipsoid for WGS84, use the wgs84Ellipsoid function.

For more information about reference spheroids, see Comparison of Reference Spheroids.

Example: spheroid = referenceEllipsoid('GRS 80');

ECEF x-coordinates of one or more points in the geocentric ECEF system, specified as a scalar, vector, matrix, or N-D array. Specify values in units that match the LengthUnit property of the spheroid argument. For example, the default length unit for the reference ellipsoid created by wgs84Ellipsoid is 'meter'.

Data Types: single | double

ECEF y-coordinates of one or more points in the geocentric ECEF system, specified as a scalar, vector, matrix, or N-D array. Specify values in units that match the LengthUnit property of the spheroid argument. For example, the default length unit for the reference ellipsoid created by wgs84Ellipsoid is 'meter'.

Data Types: single | double

ECEF z-coordinates of one or more points in the geocentric ECEF system, returned as a scalar, vector, matrix, or N-D array. Units are specified by the LengthUnit property of the spheroid argument. For example, the default length unit for the reference ellipsoid created by wgs84Ellipsoid is 'meter'.

Angle units, specified as 'degrees' (the default) or 'radians'.

Output Arguments

collapse all

Geodetic latitude of one or more points, returned as a scalar, vector, matrix, or N-D array. Values are specified in degrees within the interval [-90 90]. To use values in radians, specify the angleUnit argument as 'radians'.

Geodetic longitude of one or more points, returned as a scalar, vector, matrix, or N-D array. Values are specified in degrees within the interval [-180 180]. To use values in radians, specify the angleUnit argument as 'radians'.

Ellipsoidal height of one or more points, returned as a scalar, vector, matrix, or N-D array. Values are specified in units that match the LengthUnit property of the spheroid object. For example, the default length unit for the reference ellipsoid created by wgs84Ellipsoid is 'meter'.

For more information about ellipsoidal height, see Find Ellipsoidal Height from Orthometric Height.

Tips

  • The geocentric Cartesian (ECEF) coordinate system is fixed with respect to the Earth, with its origin at the center of the spheroid and its positive X-, Y-, and Z axes intersecting the surface at the following points:

     LatitudeLongitude Notes
    X-axis00Equator at the Prime Meridian
    Y-axis090Equator at 90-degrees East
    Z-axis900North Pole

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2012b

expand all