Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

usamap

Construct map axes for United States of America

Syntax

usamap state
usamap(state)
usamap 'conus'
usamap('conus')
usamap
usamap(latlim, lonlim)
usamap(Z, R)
h = usamap(...)
h = usamap('all')

Description

usamap state or usamap(state) constructs an empty map axes with a Lambert Conformal Conic projection and map limits covering a U.S. state or group of states specified by input state. state may be a character vector or a cell array of character vectors, where each character vector contains the name of a state or 'District of Columbia'. Alternatively, state may be a standard two-letter U.S. Postal Service abbreviation. The map axes is created in the current axes and the axis limits are set tight around the map frame.

usamap 'conus' or usamap('conus') constructs an empty map axes for the conterminous 48 states (i.e. excluding Alaska and Hawaii).

usamap with no arguments asks you to choose from a menu of state names plus 'District of Columbia', 'conus', and 'all'.

usamap(latlim, lonlim) constructs an empty Lambert Conformal map axes for a region of the U.S. defined by its latitude and longitude limits in degrees. latlim and lonlim are two-element vectors of the form [southern_limit northern_limit] and [western_limit eastern_limit], respectively.

usamap(Z, R) derives the map limits from the extent of a regular data grid georeferenced by R. R can be a geographic raster reference object, a referencing vector, or a referencing matrix.

If R is a geographic raster reference object, its RasterSize property must be consistent with size(Z).

If R is a referencing vector, it must be a 1-by-3 with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

If R is a referencing matrix, it must be 3-by-2 and transform raster row and column indices to/from geographic coordinates according to:

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

If R is a referencing matrix, it must define 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.

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

h = usamap('all') constructs three empty 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. h(1) is for the conterminous states, h(2) is for Alaska, and h(3) is for Hawaii. usamap('allequal')is the same as usamap('all'); usage of 'allequal' will be removed in a future release.

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

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

Tips

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

Was this topic helpful?