# ecef2geodetic

Transform geocentric (ECEF) to geodetic coordinates

## Syntax

• [lat,lon,h] = ecef2geodetic(spheroid,x,y,z)
example
• [lat,lon,h] = ecef2geodetic(___,angleUnit)
• [lat,lon,h] = geodetic2ecef(x,y,z,spheroid)

## Description

example

[lat,lon,h] = ecef2geodetic(spheroid,x,y,z) transforms point locations in geocentric Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates, stored in the coordinate arrays X, Y, and Z, to geodetic coordinates lat (geodetic latitude), lon (longitude), and h (ellipsoidal height). The geodetic coordinates refer to the reference body specified by the spheroid object, spheroid.

[lat,lon,h] = ecef2geodetic(___,angleUnit) uses the string angleUnit, which matches either 'degrees' or 'radians', to specify the units of the latitude and longitude coordinates.

[lat,lon,h] = geodetic2ecef(x,y,z,spheroid) This syntax is supported but not recommended. This syntax returns lat and lon in radians. spheroid can be either a spheroid or an ellipsoid vector of the form: [semimajor_axis, eccentricity]. X, Y, and Z must use the same units as the semimajor axis. In this case, H must use the same units as the semimajor axis.

## Examples

collapse all

### Convert Geocentric Coordinates to Geodetic Coordinates

Convert the geocentric Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates for Paris, France into geodetic coordinates (latitude,longitude).

x =   4.2010e+06;
y =   1.7246e+05;
z =   4.7801e+06;
wgs84 = wgs84Ellipsoid('meters');
[lat,lon,h] = ecef2geodetic(wgs84,x,y,z)
lat =

48.8562

lon =

2.3508

h =

67.3700

## Input Arguments

collapse all

### spheroid — Reference bodyspheroid object

Reference body, specified as a spheroid object: oblateSpheroid, referenceEllipsoid, or referenceSphere.

### x — Geocentric Earth-Centered Earth-Fixed Cartesian X coordinatesnumeric array

Geocentric Earth-Centered Earth-Fixed Cartesian X coordinates, specified as a numeric array.

Data Types: single | double

### y — Geocentric Earth-Centered Earth-Fixed Cartesian Y coordinatesnumeric array

Geocentric Earth-Centered Earth-Fixed Cartesian Ycoordinates, returned as a numeric array.

Data Types: single | double

### z — Geocentric Earth-Centered Earth-Fixed Cartesian Z coordinatesscalar

Geocentric Earth-Centered Earth-Fixed Cartesian Z coordinates, specified as a numeric array.

Example:

Data Types: single | double

### angleUnit — Units of the latitude and longitude coordinates'degrees' | 'radians'

Units of the latitude and longitude coordinates, specified as the character string 'degrees' or 'radians'.

Data Types: char

## Output Arguments

collapse all

### lat — Geodetic latitude in degreesgeodetic coordinate array

Geodetic latitude in degrees, returned as geodetic coordinate array.

### lon — Geodetic longitude in degreesgeodetic coordinate array

Geodetic longitude in degrees, returned as a geodetic coordinate array.

### h — Ellipsoidal heightnumeric array

Ellipsoidal height, returned as a numeric array. h is expressed in the same unit of length as the spheroid.

expand all

### 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-zxis900North Pole