mfwdtran

Project geographic features to map coordinates

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 map axes. 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 map axes is needed.

Examples

collapse all

Get geographic location data for 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 = 10×2

   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)
utmstruct = struct with fields:
     mapprojection: 'utm'
              zone: '18S'
        angleunits: 'degrees'
            aspect: 'normal'
     falsenorthing: 0
      falseeasting: 500000
       fixedorient: []
             geoid: [1x1 referenceEllipsoid]
       maplatlimit: [32 40]
       maplonlimit: [-78 -72]
      mapparallels: []
        nparallels: 0
            origin: [0 -75 0]
       scalefactor: 0.9996
           trimlat: [-80 84]
           trimlon: [-180 180]
             frame: 'off'
             ffill: 100
        fedgecolor: [0.1500 0.1500 0.1500]
        ffacecolor: 'none'
         flatlimit: [32 40]
        flinewidth: 2
         flonlimit: [-3 3]
              grid: 'off'
         galtitude: Inf
            gcolor: [0.1500 0.1500 0.1500]
        glinestyle: ':'
        glinewidth: 0.5000
    mlineexception: []
         mlinefill: 100
        mlinelimit: []
     mlinelocation: 1
      mlinevisible: 'on'
    plineexception: []
         plinefill: 100
        plinelimit: []
     plinelocation: 1
      plinevisible: 'on'
         fontangle: 'normal'
         fontcolor: [0.1500 0.1500 0.1500]
          fontname: 'Helvetica'
          fontsize: 10
         fontunits: 'points'
        fontweight: 'normal'
       labelformat: 'compass'
     labelrotation: 'off'
        labelunits: 'degrees'
     meridianlabel: 'off'
    mlabellocation: 1
    mlabelparallel: 40
       mlabelround: 0
     parallellabel: 'off'
    plabellocation: 1
    plabelmeridian: -78
       plabelround: 0

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

[x,y] = mfwdtran(utmstruct,lat,lon)
x = 10×1
105 ×

    3.2049
    3.1629
    3.2421
    3.3524
    3.2367
    3.2459
    3.2476
    3.2049
    3.2049
       NaN

y = 10×1
106 ×

    4.3077
    4.3134
    4.3187
    4.3074
    4.2943
    4.2965
    4.3043
    4.3077
    4.3077
       NaN

Introduced before R2006a