Main Content

mfwdtran

(To be removed) Project geographic features to map coordinates

mfwdtran will be removed in a future release. In most cases, use the projfwd function instead. If the mapprojection property of the current axesm-based map or specified map projection structure is 'globe', then use the geodetic2ecef function instead. For more information, see Version History.

Syntax

[x,y] = mfwdtran(lat,lon)
[x,y,z] = mfwdtran(lat,lon,alt)
[...] = mfwdtran(mstruct,...)

Description

[x,y] = mfwdtran(lat,lon) applies the forward transformation defined by the map projection in the current axesm-based map. You can use this function to convert point locations and line and polygon vertices given in latitudes and longitudes to a planar, projected map coordinate system.

[x,y,z] = mfwdtran(lat,lon,alt) applies the forward projection to 3-D input, resulting in 3-D output. If the input alt is empty or omitted, then alt = 0 is assumed.

[...] = mfwdtran(mstruct,...) requires a valid map projection structure as the first argument. In this case, no axesm-based map is needed.

Examples

collapse all

Get geographic location data for the District of Columbia.

dc = shaperead('usastatelo', 'UseGeoCoords', true,...
    'Selector',{@(name) strcmpi(name,'District of Columbia'),...
    'Name'});
lat = [dc.Lat]';
lon = [dc.Lon]';
[lat lon]
ans =

   38.9000  -77.0700
   38.9500  -77.1200
   39.0000  -77.0300
   38.9000  -76.9000
   38.7800  -77.0300
   38.8000  -77.0200
   38.8700  -77.0200
   38.9000  -77.0700
   38.9000  -77.0700
       NaN       NaN

Obtain the UTM zone for this point.

dczone = utmzone(mean(lat,'omitnan'),mean(lon,'omitnan'))
dczone =

    '18S'

Set up the UTM coordinate system based on this information.

utmstruct = defaultm('utm'); 
utmstruct.zone = dczone;  
utmstruct.geoid = wgs84Ellipsoid;
utmstruct = defaultm(utmstruct);

Project the District of Columbia data from geographic coordinates into map coordinates for UTM zone 18S.

[x,y] = mfwdtran(utmstruct,lat,lon)
x =

   1.0e+05 *

    3.2049
    3.1629
    3.2421
    3.3524
    3.2367
    3.2459
    3.2476
    3.2049
    3.2049
       NaN


y =

   1.0e+06 *

    4.3077
    4.3134
    4.3187
    4.3074
    4.2943
    4.2965
    4.3043
    4.3077
    4.3077
       NaN

Version History

Introduced before R2006a

expand all

R2023a: Warns

The mfwdtran function issues a warning that it will be removed in a future release. In most cases, use the projfwd function instead. If the mapprojection field of the current axesm-based map or specified map projection structure is 'globe', then use the geodetic2ecef function instead.

This table shows some typical usages of the mfwdtran function and how to update your code to use the projfwd function instead.

Will Be RemovedRecommended
[x,y,z] = mfwdtran(lat,lon);
mstruct = gcm;
[x,y] = projfwd(mstruct,lat,lon);
[x,y,z] = mfwdtran(mstruct,lat,lon);
[x,y] = projfwd(mstruct,lat,lon);

This table shows some typical usages of the mfwdtran function and how to update your code to use the geodetic2ecef function instead.

Will Be RemovedRecommended
[x,y,z] = mfwdtran(lat,lon,alt);
mstruct = gcm;
[x,y,z] = geodetic2ecef(lat,lon,alt,mstruct.geoid);
[x,y,z] = mfwdtran(mstruct,lat,lon,alt);
[x,y,z] = geodetic2ecef(lat,lon,alt,mstruct.geoid);

If the value of the mapprojection field of the map projection structure is listed in this table, then all linear units in the map projection structure must be in meters. In addition, the projfwd function returns coordinates in meters. You can convert the coordinates to other units using the unitsratio function.

ValueProjection Name

'tranmerc'

Transverse Mercator

'mercator'

Mercator

'lambertstd'

Lambert Conformal Conic

'eqaazim'

Lambert Azimuthal Equal Area

'eqaconicstd'

Albers Equal-Area Conic

'eqdazim'

Azimuthal Equidistant

'eqdconicstd'

Equidistant Conic

'ups'

Polar Stereographic

'stereo'

Oblique Stereographic

'eqdcylin'

Equirectangular

'cassinistd'

Cassini-Soldner

'gnomonic'

Gnomonic

'miller'

Miller Cylindrical

'ortho'

Orthographic

'polyconstd'

Polyconic

'robinson'

Robinson

'sinusoid'

Sinusoidal

'vgrint1'

Van der Grinten

'eqacylin'

Equal Area Cylindrical