defaultm

Initialize or reset map projection structure

Syntax

mstruct = defaultm(projid)
mstruct = defaultm(mstruct)

Description

mstruct = defaultm(projid) initializes a map projection structure, where projid is a string scalar or character vector that matches one of the entries in the last column of the table displayed by the maps function. The output mstruct is a map projection structure. It is a scalar structure whose fields correspond to Map Axes Properties.

mstruct = defaultm(mstruct) checks an existing map projection structure, sets empty properties, and adjusts dependent properties. The Origin, FLatLimit, FLonLimit, MapLatLimit, and MapLonLimit properties may be adjusted for compatibility with each other and with the MapProjection property and (in the case of UTM or UPS) the Zone property.

With defaultm, you can construct a map projection structure (mstruct) that contains all the information needed to project and unproject geographic coordinates using , projinv, projfwd, vfwdtran, or vinvtran without creating a map axes or making any use at all of MATLAB® graphics. Relevant parameters in the mstruct include the projection name, angle units, zone (for UTM or UPS), origin, aspect, false easting, false northing, and (for conic projections) the standard parallel or parallels. In very rare cases you might also need to adjust the frame limit (FLatLimit and FLonLimit) or map limit (MapLatLimit and MapLonLimit) properties.

You should make exactly two calls to defaultm to set up your mstruct, using the following sequence:

  1. Construct a provisional version containing default values for the projection you've selected: mstruct = defaultm(projection);

  2. Assign appropriate values to mstruct.angleunits, mstruct.zone, mstruct.origin, etc.

  3. Set empty properties and adjust interdependent properties as needed to finalize your map projection structure: mstruct = defaultm(mstruct);

If you've set field prop1 of mstruct to value1, field prop2 to value2, and so forth, then the following sequence

mstruct = defaultm(projection);
mstruct.prop1 = value1;
mstruct.prop2 = value2;
...
mstruct = defaultm(mstruct);

produces exactly the same result as the following:

f = figure;
ax = axesm(projection, prop1, value1, prop2, value2, ...);
mstruct = getm(ax);
close(f)
but it avoids the use of graphics and is more efficient.

Note

Angle-valued properties are in degrees by default. If you want to work in radians instead, you can make the following assignment in between your two calls to defaultm:

mstruct.angleunits = 'radians';

You must also use values in radians when assigning any angle-valued properties (such as mstruct.origin, mstruct.parallels, mstruct.maplatlimit, mstruct.maplonlimit, etc.).

See the Mapping Toolbox™ User's Guide section on Work in UTM Without a Displayed Map for information and an example showing the use of defaultm in combination with UTM.

Examples

collapse all

Create an empty map projection structure for a Mercator projection:

mstruct = defaultm('mercator')
mstruct = 
     mapprojection: 'mercator'
              zone: []
        angleunits: 'degrees'
            aspect: 'normal'
      falseeasting: []
     falsenorthing: []
       fixedorient: []
             geoid: [1 0]
       maplatlimit: []
       maplonlimit: []
      mapparallels: 0
        nparallels: 1
            origin: []
       scalefactor: []
           trimlat: [-86 86]
           trimlon: [-180 180]
             frame: []
             ffill: 100
        fedgecolor: [0 0 0]
        ffacecolor: 'none'
         flatlimit: []
        flinewidth: 2
         flonlimit: []
              grid: []
         galtitude: Inf
            gcolor: [0 0 0]
        glinestyle: ':'
        glinewidth: 0.5000
    mlineexception: []
         mlinefill: 100
        mlinelimit: []
     mlinelocation: []
      mlinevisible: 'on'
    plineexception: []
         plinefill: 100
        plinelimit: []
     plinelocation: []
      plinevisible: 'on'
         fontangle: 'normal'
         fontcolor: [0 0 0]
          fontname: 'helvetica'
          fontsize: 9
         fontunits: 'points'
        fontweight: 'normal'
       labelformat: 'compass'
     labelrotation: 'off'
        labelunits: []
     meridianlabel: []
    mlabellocation: []
    mlabelparallel: []
       mlabelround: 0
     parallellabel: []
    plabellocation: []
    plabelmeridian: []
       plabelround: 0

Now change the map origin to [0 90 0], and fill in default projection parameters accordingly:

mstruct.origin = [0 90 0];
mstruct = defaultm(mstruct)
mstruct = 
     mapprojection: 'mercator'
              zone: []
        angleunits: 'degrees'
            aspect: 'normal'
      falseeasting: 0
     falsenorthing: 0
       fixedorient: []
             geoid: [1 0]
       maplatlimit: [-86 86]
       maplonlimit: [-90 270]
      mapparallels: 0
        nparallels: 1
            origin: [0 90 0]
       scalefactor: 1
           trimlat: [-86 86]
           trimlon: [-180 180]
             frame: 'off'
             ffill: 100
        fedgecolor: [0 0 0]
        ffacecolor: 'none'
         flatlimit: [-86 86]
        flinewidth: 2
         flonlimit: [-180 180]
              grid: 'off'
         galtitude: Inf
            gcolor: [0 0 0]
        glinestyle: ':'
        glinewidth: 0.5
    mlineexception: []
         mlinefill: 100
        mlinelimit: []
     mlinelocation: 30
      mlinevisible: 'on'
    plineexception: []
         plinefill: 100
        plinelimit: []
     plinelocation: 15
      plinevisible: 'on'
         fontangle: 'normal'
         fontcolor: [0 0 0]
          fontname: 'Helvetica'
          fontsize: 10
         fontunits: 'points'
        fontweight: 'normal'
       labelformat: 'compass'
     labelrotation: 'off'
        labelunits: 'degrees'
     meridianlabel: 'off'
    mlabellocation: 30
    mlabelparallel: 86
       mlabelround: 0
     parallellabel: 'off'
    plabellocation: 15
    plabelmeridian: -90
       plabelround: 0

This example shows how to perform the same projection computations that are done within Mapping Toolbox display commands by calling the defaultm and projfwd functions.

Create an empty map projection structure for a Sinusoidal projection, using the defaultm function. The function returns an mstruct .

mstruct = defaultm('sinusoid');

Set the map limits for the mstruct . To populate the fields of the map projection structure and ensure the effects of property settings are properly implemented, call defaultm a second time.

mstruct.maplonlimit = [-150 -30];
mstruct.geoid = referenceEllipsoid('grs80','kilometers');
mstruct = defaultm(mstruct);

Load coastline data and trim it to the map limits.

load coastlines
[latt,lont] = maptriml(coastlat,coastlon, ...
     mstruct.maplatlimit,mstruct.maplonlimit);

Project the latitude and longitude vectors into plane coordinates with the Sinusoidal projection and display the result. The plot shows that the data are projected in the specified aspect.

[x,y] = projfwd(mstruct,latt,lont);
figure
plot(x,y)
axis equal

See Also

| | | |

Introduced before R2006a