geodetic2ecef

Transform geodetic coordinates to geocentric Earth-centered Earth-fixed

Description

example

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

[X,Y,Z] = geodetic2ecef(___,angleUnit) specifies the units for latitude and longitude. Specify angleUnit as 'degrees' (the default) or 'radians'.

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

Examples

collapse all

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

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

wgs84 = wgs84Ellipsoid('kilometer');

Specify the geodetic coordinates of Paris. Specify h as ellipsoidal height in kilometers.

lat = 48.8562;
lon = 2.3508;
h = 0.0674;

Then, calculate the ECEF coordinates of Paris. In this example, x and y display in scientific notation.

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

Reverse the transformation using the ecef2geodetic function.

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

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 Reference Spheroids.

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

Geodetic latitude of one or more points, specified as a scalar, vector, matrix, or N-D array. Specify the values in degrees. To use values in radians, specify the angleUnit argument as 'radians'.

Data Types: single | double

Geodetic longitude of one or more points, specified as a scalar, vector, matrix, or N-D array. Specify the values in degrees. To use values in radians, specify the angleUnit argument as 'radians'.

Data Types: single | double

Ellipsoidal height of one or more points, specified as a scalar, vector, matrix, or N-D array. Specify values 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'.

Data Types: single | double

Units of angles, specified as 'degrees' (the default) or 'radians'.

Data Types: char | string

Output Arguments

collapse all

ECEF x-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'.

ECEF y-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'.

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'.

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

Introduced in R2012b