Once a map axes object has been created with
axesm, whether map
data is displayed or not, it is possible to change the current projection as well as
many of its parameters. You can use
setm or the
maptool UI to reset the projection. The rest of this section
describes the considerations and parameters involved in switching projections in a map
axes. Additional details are given for doing this with the
function in Change Map Projections Using geoshow.
When you switch from one projection to another,
setm clears out
settings that were specific to the earlier projection, updates the map frame and
graticule, and generally keeps the map covering the same part of the world—even
when switching between azimuthal and non-azimuthal projections. But in some cases, you
might need to further adjust the map axes properties to achieve proper appearance.
Settings that are suitable for one projection might not be appropriate for another. Most
often, you'll need to update the positioning of your meridian and parallel
This example shows how to change the projection of a map and update the meridian and parallel labels.
Create a Mercator projection with meridian and parallel labels.
axesm mercator framem on; gridm on; mlabel on; plabel on setm(gca,'LabelFormat','signed') axis off
Get the default map and frame latitude limits for the Mercator projection. Note that both the frame and map latitude limits are set to 86 degrees north and south for the Mercator projection to maintain a safe distance from the singularity at the poles.
ans = 2×2 -86 86 -86 86
Switch the projection to an orthographic azimuthal.
Specify new locations for the meridian and parallel labels.
setm(gca,'MLabelParallel',0,'PLabelMeridian',-90, ... 'PLabelMeridian',-30)
This example shows how to switch from one projection to another and reset the origin and frame limits, especially when mapping a small portion of the Earth.
Construct an empty map axes for a region of the United States in the Lambert Conformal Conic projection (the default projection for the
latlim = [32 42]; lonlim = [-125 -111]; h = usamap(latlim, lonlim);
usastatehi shapefile and return a subset of the shapefile contents, as defined by the latitude and longitude limits. The
shaperead function returns the data in a structure called
states = shaperead('usastatehi', 'UseGeoCoords', true, ... 'BoundingBox', [lonlim', latlim']);
Save the latitude and longitude data from the structure in the vectors
lat = [states.Lat]; lon = [states.Lon];
Project patch objects on the map axes.
patchm(lat, lon, [0.5 0.5 1])
Change the projection to Lambert Equal Area Azimuthal and reset the origin and frame limits.
setm(gca,'MapProjection','eqaazim','Origin',[37 -118], ... 'FLatLimit',[-Inf 6]) setm(gca,'mlinelocation',2,'plinelocation',2) tightmap