Main Content


Display map data without projection



mapshow(x,y) displays the coordinate vectors x and y as lines. You can optionally display the coordinate vectors as points or polygons by using the DisplayType name-value pair argument.

mapshow(S) displays the vector geographic features stored in S as points, multipoints, lines, multilines, polygons, or multipolygons according to the geometry of S.

You can optionally specify symbolization rules using the SymbolSpec name-value pair argument.

mapshow(x,y,Z) displays a geolocated data grid, Z. You can optionally display the data as a surface, mesh, texture map, or contour by using the DisplayType name-value pair argument.


mapshow(Z,R) displays a regular data grid, Z, with referencing object R. You can optionally display the data as a surface, mesh, texture map, or contour by using the DisplayType name-value pair argument. If DisplayType is 'texturemap', then mapshow displays the image as a texture map on a zero-elevation surface (by setting ZData values to 0).

mapshow(x,y,I) and

mapshow(x,y,X,cmap) display a geolocated image as a texture map on a zero-elevation surface. The geolocated image can be a truecolor, grayscale, or binary image, I, or an indexed image X with colormap cmap. x and y are geolocation arrays in map coordinates. Examples of geolocated images include a color composite from a satellite swath or an image originally referenced to a different coordinate system.


mapshow(I,R) and

mapshow(X,cmap,R) display an image georeferenced to map coordinates through the referencing object R. The mapshow function constructs an image object if the display geometry permits. Otherwise, mapshow displays the image as a texture map on a zero-elevation surface (by setting ZData values to 0).

mapshow(filename) displays data from the file specified according to the type of file format.


mapshow(___,Name,Value) modifies the displayed map by using name-value pair arguments to set the DisplayType and SymbolSpec parameters. You can also use name-value pairs to set any MATLAB® graphics properties. Parameter names can be abbreviated, and case does not matter.

mapshow(ax,___) sets the parent axes to ax.

h = mapshow(___) returns a handle to a MATLAB graphics object.


collapse all

Overlay Boston roads on an orthophoto. Note that mapshow draws a new layer in the axes rather than replacing its contents.

Display image.

mapshow boston.tif
axis image off manual

Convert Boston roads to units of survey feet and overlay on orthophoto.

S = shaperead('boston_roads.shp');
surveyFeetPerMeter = unitsratio('sf','meter');
x = surveyFeetPerMeter * [S.X];
y = surveyFeetPerMeter * [S.Y];

Import a shapefile containing a network of road segments in Concord, MA as a geospatial table. Display the road segments using dotted lines.

roads = readgeotable("boston_roads.shp");

Create a symbol specification to distinguish between different types of roads. For example, you can hide very minor roads (CLASS=6) by turning off their visibility and make major roads (CLASS=1-4) more visible by increasing their line widths. This symbol specification also uses color to distinguish between types of roads.

roadspec = makesymbolspec('Line',...
                          {'ADMIN_TYPE',0,'Color','cyan'}, ...
                          {'CLASS',[1 4],'LineWidth',2});

Display the vector data using the symbol specification.


Create a symbol specification and specify the default color used for lines. As seen in the previous example, the default is blue. This example sets the default to black.

roadspec = makesymbolspec('Line',...
                              {'Default', 'Color', 'black'}, ...
                              {'ADMIN_TYPE',0,'Color','c'}, ...
                              {'CLASS',[1 4],'LineWidth',2});

Display the vector data, using the symbol specification. Note how the major roads displayed in blue in the previous example are now black.


Create a symbol specification, setting various properties.

roadspec = makesymbolspec('Line',...
                              {'Default', 'Color', 'yellow'}, ...
                              {'ADMIN_TYPE',0,'Color','c'}, ...
                              {'CLASS',[1 4],'LineWidth',2});

Display the vector data, specifying the color on the command line.

mapshow('boston_roads.shp', 'Color', 'black', 'SymbolSpec', roadspec);

Import an orthophoto of Concord, MA, along with a map cells reference object and a colormap. Display the orthophoto using the mapshow function.

[ortho,R,cmap] = readgeoraster("concord_ortho_w.tif");

Import and display a polygon representing a pond in the middle of the orthophoto.

Import a shapefile containing hydrographic data for Concord as a geospatial table. Create a subtable that contains the 14th row of the table, which is the row containing the pond. Verify that the subtable contains polygon data by querying the Shape variable of the table.

hydro = readgeotable("concord_hydro_area.shp");
pond = hydro(14,:);
ans = 
  mappolyshape with properties:

              NumRegions: 1
                NumHoles: 3
                Geometry: "polygon"
    CoordinateSystemType: "planar"
            ProjectedCRS: [1x1 projcrs]

Display the polygon over the orthophoto.


Read SDTS terrain data for Mount Washington. Get information such as missing data indicators using georasterinfo. Replace the missing data with NaN values using standardizeMissing.

[Z,R] = readgeoraster('MtWashington-ft.grd','OutputType','double');
info = georasterinfo('MtWashington-ft.grd');
Z = standardizeMissing(Z,info.MissingDataIndicator);

View the terrain data as a mesh. Apply a colormap appropriate for terrain data using demcmap.


View the terrain data as a surface.


View the terrain data as a 3-D surface.

axis normal

Read the terrain data files for Mount Washington and Mount Dartmouth. To plot the data as a surface using mapshow, the raster must be of type single or double. Specify the data type for the raster using the 'OutputType' name-value pair.

[ZWash,RWash] = readgeoraster('MtWashington-ft.grd','OutputType','double');
[ZDart,RDart] = readgeoraster('MountDartmouth-ft.grd','OutputType','double');

Find missing data using the georasterinfo function. The function returns an object with a MissingDataIndicator property that indicates which value represents missing data. Replace the missing data with NaN values using the standardizeMissing function.

infoWash = georasterinfo('MtWashington-ft.grd');
ZWash = standardizeMissing(ZWash,infoWash.MissingDataIndicator);

infoDart = georasterinfo('MountDartmouth-ft.grd');
ZDart = standardizeMissing(ZDart,infoDart.MissingDataIndicator);

Display the terrain data under the contour lines and labels by specifying the 'ZData' name-value pair as a matrix of zeros. Apply a colormap appropriate for terrain data using demcmap.

hold on
axis equal

Overlay black contour lines and labels.


Input Arguments

collapse all

x- or y coordinates, specified as a numeric vector or an M-by-N numeric matrix. x and y must be the same size. If x and y are matrices, they represent coordinate arrays or a geolocation array in map coordinates. x and y may contain embedded NaNs to delimit individual lines or polygon parts.

Geographic features, specified as one of the following:

  • A geospatial table. The Shape variable of the table must contain mappointshape, maplineshape, or mappolyshape objects. The mapshow function does not support geospatial tables containing more than one type of shape object. For more information about geospatial tables, see Create Geospatial Tables.

  • A mappoint vector.

  • A mapshape vector.

  • A map structure array (mapstruct) with X and Y coordinate fields.

The mapshow function assumes the coordinates are map coordinates.

If you specify a geopoint vector, a geoshape vector, or a geographic structure array (geostruct) with Lat and Lon coordinate fields, then the mapshow function projects the coordinates using a Plate Carrée projection and issues a warning. If you specify a geospatial table containing geopointshape, geolineshape, or geopolyshape objects, then the mapshow function throws an error. In these cases, use the geoshow function instead.

Data grid, specified as an M-by-N array that may contain NaN values. Z is either a georeferenced data grid, or a regular data grid associated with a geographic reference R. The size of x and y must match the size of Z.

Data Types: double

Map reference, specified as one of the following. For more information about referencing matrices, see Georeferenced Raster Data.

Map raster reference object

MapCellsReference or MapPostingsReference or GeographicPostingsReference map raster reference object that relates the subscripts of Z to map coordinates. The RasterSize property must be consistent with the size of the data grid, size(Z).

If R is a MapPostingsReference object, then the 'image' and 'texturemap' values of DisplayType are not accepted.


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

[x y] = [row col 1] * R

Truecolor, grayscale, or binary image, specified as an M-by-N-by-3 array for truecolor images, or an M-by-N array for grayscale or binary images. x and y must be M-by-N arrays.

Indexed image with color map defined by cmap, specified as an M-by-N array. x and y must be M-by-N arrays.

Color map of indexed image X, specified as an c-by-3 numeric matrix. There are c colors in the color map, each represented by a red, green, and blue pixel value.

File name, specified as a string scalar or character vector. mapshow automatically sets the DisplayType parameter according to the format of the data.

Shape file'point', 'multipoint', 'line', or 'polygon'
TIFF/JPEG/PNG with a world file 'image'
ARC ASCII GRID'surface' (can be overridden)
SDTS raster'surface' (can be overridden)

Data Types: char | scalar

Parent axes, specified as an axes object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'DisplayType','point'

Type of graphic display for the data, specified as the comma-separated pair consisting of 'DisplayType' and one of the following values.

Data FormatDisplay TypeType of Property
Vector'point'line marker
'multipoint'line marker

Valid values of DisplayType depend on the format of the map data. For example, if the map data is a geolocated image or georeferenced image, then the only valid value of DisplayType is 'image'.

Different display types support different map data class types:

Display TypeSupported Class Types
Surfacesingle and double
Texture mapAll numeric types and logical

Symbolization rules to be used for displaying vector data, specified as a symbolSpec structure returned by makesymbolspec. When both SymbolSpec and one or more graphics properties are specified, the graphics properties will override any settings in the symbolSpec structure.

To change the default symbolization rule for a Name,Value pair in the symbolSpec structure, prefix the word 'Default' to the graphics property name.

Output Arguments

collapse all

Parent axes, returned as a handle to a MATLAB graphics object or, in the case of polygons, a modified patch object. If a mapstruct or shapefile name is input, mapshow returns the handle to an hggroup object with one child per feature in the mapstruct or shapefile. In the case of a polygon mapstruct or shapefile, each child is a modified patch object; otherwise it is a line object.


  • If you do not want mapshow to draw on top of an existing map, create a new figure or subplot before calling it.

  • You can use mapshow to display vector data in an axesm figure. However, you should not subsequently change the map projection using setm.

  • If you display a polygon, do not set 'EdgeColor' to either 'flat' or 'interp'. This combination may result in a warning.

Version History

Introduced before R2006a

expand all