Main Content

usamap

Construct map axes for United States of America

Description

example

usamap state and

usamap(state) create an empty map axes with a Lambert Conformal Conic projection and map limits covering a U.S. state or group of states specified by state. The map axes is created in the current axes and the axis limits are set tight around the map frame.

usamap 'conus' and

usamap('conus') create an empty map axes for the conterminous 48 states (that is, all states excluding Alaska and Hawaii).

example

usamap with no arguments presents a menu from which you can select a single state, the District of Columbia, the conterminous 48 states, or all states.

usamap(latlim,lonlim) creates an empty Lambert Conformal map axes for a region of the U.S. defined by its latitude and longitude limits in degrees.

usamap(Z,R) derives the map limits from the extent of a regular data grid, Z, georeferenced by R.

h = usamap(___) returns the handle of the map axes.

example

h = usamap('all') constructs three empty map axes, inset within a single figure, for the conterminous states, Alaska, and Hawaii, with a spherical Earth model and other projection parameters suggested by the U.S. Geological Survey. The maps in the three axes are shown at approximately the same scale. The handles for the three map axes are returned in h.

usamap('allequal') is the same as usamap('all'), but usage of 'allequal' will be removed in a future release.

Examples

collapse all

Make a map of the state of Alabama only.

figure
usamap('Alabama')
alabamahi = shaperead('usastatehi', 'UseGeoCoords', true,...
            'Selector',{@(name) strcmpi(name,'Alabama'), 'Name'});
geoshow(alabamahi, 'FaceColor', [0.3 1.0, 0.675])

Add text to label the state.

textm(alabamahi.LabelLat, alabamahi.LabelLon, alabamahi.Name,...
  'HorizontalAlignment', 'center')

Make a map of a contiguous landmass that contains California and Montana.

figure
ax = usamap({'CA','MT'});
set(ax, 'Visible', 'off')
latlim = getm(ax, 'MapLatLimit');
lonlim = getm(ax, 'MapLonLimit');
states = shaperead('usastatehi',...
        'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
geoshow(ax, states, 'FaceColor', [0.5 0.5 1])

Add labels to each state.

lat = [states.LabelLat];
lon = [states.LabelLon];
tf = ingeoquad(lat, lon, latlim, lonlim);
textm(lat(tf), lon(tf), {states(tf).Name}, ...
   'HorizontalAlignment', 'center')

Map the conterminous United States with a different fill color for each state.

figure
ax = usamap('conus');
states = shaperead('usastatelo', 'UseGeoCoords', true,...
  'Selector',...
  {@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
faceColors = makesymbolspec('Polygon',...
    {'INDEX', [1 numel(states)], 'FaceColor', ... 
    polcmap(numel(states))}); %NOTE - colors are random
geoshow(ax, states, 'DisplayType', 'polygon', ...
   'SymbolSpec', faceColors)

Set optional display settings.

framem off; gridm off; mlabel off; plabel off;

Map the USA with separate axes for Alaska and Hawaii.

figure
ax = usamap('all');
set(ax, 'Visible', 'off')
states = shaperead('usastatelo', 'UseGeoCoords', true);
names = {states.Name};
indexHawaii = strcmp('Hawaii',names);
indexAlaska = strcmp('Alaska',names);
indexConus = 1:numel(states);
indexConus(indexHawaii|indexAlaska) = []; 
stateColor = [0.5 1 0.5];

Display the three regions.

geoshow(ax(1), states(indexConus),  'FaceColor', stateColor)
geoshow(ax(2), states(indexAlaska), 'FaceColor', stateColor)
geoshow(ax(3), states(indexHawaii), 'FaceColor', stateColor)

Hide the frame.

for k = 1:3
    setm(ax(k), 'Frame', 'off', 'Grid', 'off',...
      'ParallelLabel', 'off', 'MeridianLabel', 'off')
end

Input Arguments

collapse all

State to display, specified as a string scalar, string array, character vector or cell array of character vectors. Permissible values include names of states, standard two-letter U.S. Postal Service abbreviations for states, and 'District of Columbia'.

Example: usamap({'Maine','Florida'}) sets the map limits to cover the region spanning from Maine to Florida.

Latitude limits, specified as a two-element vector of the form [southern_limit northern_limit].

Longitude limits, specified as a two-element vector of the form [western_limit eastern_limit].

Data grid, specified as an M-by-N array. Z is a regular data grid associated with a geographic reference R.

Geographic reference, specified as one of the following.

TypeDescription
Geographic raster reference object

GeographicCellsReference or GeographicPostingsReference geographic raster reference object. The RasterSize property must be consistent with the size of the data grid, size(Z).

Vector

1-by-3 numeric vector with elements:

[cells/degree northern_latitude_limit western_longitude_limit]
Matrix

3-by-2 numeric matrix that transforms raster row and column indices to or from geographic coordinates according to:

[lon lat] = [row col 1] * R

R defines a (non-rotational, non-skewed) relationship in which each column of the data grid falls along a meridian and each row falls along a parallel.

For more information about referencing vectors and matrices, see Georeferenced Raster Data.

Output Arguments

collapse all

Handle of the map axes, returned as a handle object.

If you use the syntax h = usamap('all'), then h is array of handle objects. h(1) is for the conterminous states, h(2) is for Alaska, and h(3) is for Hawaii.

Tips

  • All axes created with usamap are initialized with a spherical Earth model having a radius of 6,371,000 meters.

  • In some cases, usamap uses tightmap to adjust the axis limits tight around the map. If you change the projection, or just want more white space around the map frame, use tightmap again or axis auto.

  • axes(h(n)), where n = 1, 2, or 3, makes the desired axes current.

  • set(h,'Visible','on') makes the axes visible.

  • axesscale(h(1)) resizes the axes containing Alaska and Hawaii to the same scale as the conterminous states.

Introduced before R2006a