Main Content

local2latlon

将当地的笛卡尔坐标转换为地理坐标

Description

example

[lat,lon,alt] = local2latlon(xEast,yNorth,zUp,origin)converts point locations given byxEast,yNorth, andzUpfrom local Cartesian coordinates to geographic coordinates returned aslat,lon, andalt.originspecifies the anchor of the local coordinate system as a three-element vector of the form [latOrigin,,altOrigin]. Local coordinatesxEast,yNorth, andzUpalign with the east, north, and up directions, respectively.altandaltOriginare altitudes as typically returned by GPS sensors.

Examples

collapse all

Establish an anchor point in the geographic coordinate system. These latitude and longitude coordinates specify Boston, MA.

origin = [42.3648, -71.0214, 10.0];

Generate local route in Cartesian coordinates,x,y,andz.

z = zeros(1,101);% maintain height of 0 mx = 0:1000:100000;% 100 km in 1 km incrementsy = x;% 100公里没有移动rtheast

Convert the local route coordinates to geographic coordinates, latitude and longitude.

[lat,lon] = local2latlon(x,y,z,origin);

Visualize the route on a map.

zoomLevel = 12; player = geoplayer(lat(1),lon(1),zoomLevel); plotRoute(player,lat,lon);

Input Arguments

collapse all

x-coordinates in the local Cartesian coordinate system, specified as a numeric scalar or vector, in meters.

Example:-2.7119

Data Types:single|double

y-coordinates in the local Cartesian coordinate system, specified as a numeric scalar or vector, in meters.

Example:-7.0681

Data Types:single|double

y以米为单位的数字标量或向量指定的本地笛卡尔坐标系中的坐标。

Example:-0.2569

Data Types:single|double

Anchor of local coordinate system, specified as a three-element vector of the form [latOrigin,,altOrigin].

Example:[42.3648 -71.0214 10]

Data Types:single|double

Output Arguments

collapse all

Latitude, in degrees, returned as a numeric scalar or vector.

latis the same class asxEast. However, if any of the input arguments is of classsingle, thenlatis of classsingle.

Longitude, in degrees, returned as a numeric scalar or vector.

lonis the same class asyNorth. However, if any of the input arguments is of classsingle, thenlonis of classsingle.

Altitude, in meters, returned as a numeric scalar or vector, the same class aszUp.

altis the same class aszUp. However, if any of the input arguments is of classsingle, thenaltis of classsingle.

Tips

  • The latitude and longitude of the geographic coordinate system use the WGS84 standard that is commonly used by GPS receivers.

  • This function defines altitude as the height, in meters, above the WGS84 reference ellipsoid.

  • Some GPS receivers use standards other than WGS84. Conversions using other ellipsoids are available in the Mapping Toolbox. This function addresses the most common conversion between geographic locations and Cartesian coordinates used by the on-board sensors of a vehicle.

Version History

Introduced in R2020a