Main Content

Inset Maps

An inset map is a smaller map displayed inside a larger map. You can use an inset map to create geographic context for the larger map. For this example, create a map of Massachusetts and include an inset map of the northeastern United States.

Read USA state boundaries from a shapefile. Indicate that file contains latitude and longitude coordinates by specifying the UseGeoCoords name-value argument.

states = shaperead('usastatehi.shp','UseGeoCoords',true);

Extract the state boundaries of Massachusetts and find their latitude and longitude limits.

ma = states(strcmp({states.Name},'Massachusetts'));
latlim = [min(ma.Lat) max(ma.Lat)];
lonlim = [min(ma.Lon) max(ma.Lon)];

Create a map using the latitude and longitude coordinates. Set the face frame color of the map to light blue. Display the USA boundaries as light-brown polygons and the Massachusetts boundaries as green polygons.

figure
h1 = usamap(latlim,lonlim);
setm(h1,'FFaceColor','#B7E9F7')
geoshow(states,'FaceColor','#EFE6DC')
geoshow(ma,'FaceColor','#90EE90')

Create an inset map. To do this, first create axes in the lower-left of the map frame. Place a map with latitude and longitude limits that contain Pennsylvania and Maine inside the axes, remove the parallel and meridian labels, and remove the grid lines. Then, display the USA boundaries as gray polygons and the Massachusetts boundaries as green polygons.

h2 = axes('Position',[0.15 0.25 0.2 0.2]);
usamap({'PA','ME'})
setm(h2,'FFaceColor','w')
plabel off
mlabel off
gridm off
geoshow(states,'FaceColor','#EDEDED')
geoshow(ma,'FaceColor','#90EE90')

See Also

Functions

Related Topics