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.

mapshow

Display map data without projection

Syntax

mapshow(x,y)
mapshow(s)
mapshow(x,y,z)
mapshow(Z,R)
mapshow(x,y,image)
mapshow(x,y,A,cmap)
mapshow(image,R)
mapshow(A,cmap,R)
mapshow(filename)
mapshow(___,name,value,...)
mapshow(ax,___)
h = mapshow(___)

Description

mapshow(x,y) displays the coordinate vectors x and y. The default behavior for mapshow is to display x and y as lines.

mapshow(s) displays the vector geographic features stored in the geographic data structure s as points, multipoints, lines, or polygons according to the Geometry field of s. If s includes X and Y fields, then these fields are used directly to plot features in map coordinates. If s includes Lat and Lon fields instead, the coordinates are projected with the Plate Carrée projection and a warning is issued.

mapshow(x,y,z) displays a geolocated data grid. x and y are M-by-N coordinate arrays, and z is an M-by-N array of class double.

mapshow(Z,R) displays a regular data grid, Z.

mapshow(x,y,image) or mapshow(x,y,A,cmap) displays a geolocated image as a texturemap on a zero-elevation surface. x and y are geolocation arrays in map coordinates. x, y, and the image array must match in size. Examples of geolocated images include a color composite from a satellite swath or an image originally referenced to a different coordinate system.

mapshow(image,R) or mapshow(A,cmap,R) displays an image georeferenced to map coordinates through R. The mapshow function constructs an image object if the display geometry permits. Otherwise, mapshow displays the image as a texturemap on a zero-elevation surface.

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

mapshow(___,name,value,...) specifies parameters and corresponding values that modify the type of display or set MATLAB® graphics properties. Parameter names can be abbreviated, and case does not matter.

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

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

Input Arguments

x

Coordinate vector, M-by-N coordinate array, or geolocation array in map coordinates, depending on the syntax. x can contain embedded NaNs to delimit individual lines or polygon parts.

y

Coordinate vector, M-by-N coordinate array, or geolocation array in map coordinates, depending on the syntax. y can contain embedded NaNs to delimit individual lines or polygon parts.

z

M-by-N array. z can contain NaN values.

s

Geographic data structure.

Z

Regular data grid.

R

Referencing matrix or an object of class MapCellsReference or MapPostingsReference that relates the subscripts of Z to map coordinates. If R is a map.rasterref.MapRasterReference object with raster interpretation 'postings', then mapshow does not accept the 'image' and 'texturemap' display types.

image

Grayscale, logical, or truecolor image.

A

Indexed image.

cmap

Colormap.

ax

Axes object.

filename

Name of file.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'SymbolSpec'

A structure returned by makesymbolspec that specifies the symbolization rules used for vector data. 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, prefix the word 'Default' to the graphics property name.

'DisplayType'

Type of graphic display for the data. You can set any MATLAB Graphics line, patch, image, surface, and contour properties. See the table for links to the MATLAB documentation on these properties.

Data TypeDisplayTypeType of Property

Vector

'point'

line marker

'multipoint'

line marker

'line' (default)

line

'polygon'

patch

Image

'image' or 'surface'

image or surface

Grid

'surface'

surface

'mesh'

surface

'texturemap'

surface

'contour'

contour

If DisplayType is 'texturemap', mapshow constructs a surface with ZData values set to 0.

Set the DisplayType to 'image' if you are using the syntax mapshow(image, R, ...).

When using the filename argument, the DisplayType parameter is automatically set, according to the following table:

Format

DisplayType

Shapefile

'point', 'line', or 'polygon'

GeoTIFF

'image'

TIFF/JPEG/PNG with a world file

'image'

ARC ASCII GRID

'surface' (can be overridden)

SDTS raster

'surface' (can be overridden)

Output Arguments

h

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.

Class Support

Display TypeSupported Class Types
Imagelogical, uint8, uint16, and double
Surfacesingle and double
Texture mapAll numeric types and logical

Examples

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.

figure
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];
mapshow(x,y)

Read the vector data and display it using a dotted line.

roads = shaperead('boston_roads.shp');
figure
mapshow(roads,'LineStyle',':');

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'}, ...
                          {'ADMIN_TYPE',3,'Color','red'},...
                          {'CLASS',6,'Visible','off'},...
                          {'CLASS',[1 4],'LineWidth',2});

Display the vector data using the symbol specification.

figure
mapshow('boston_roads.shp','SymbolSpec',roadspec);

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'}, ...
                              {'ADMIN_TYPE',3,'Color','r'},...
                              {'CLASS',6,'Visible','off'},...
                              {'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.

figure
mapshow('boston_roads.shp','SymbolSpec',roadspec);

Create a symbol specification, setting various properties.

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

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

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

Read orthophoto.

[ortho, cmap] = imread('concord_ortho_w.tif');

Read vector data.

R = worldfileread('concord_ortho_w.tfw', 'planar', size(ortho));

Display the orthophoto with the vector data.

figure
mapshow(ortho,cmap,R)

Read polygon vector data representing a pond with three islands (feature 14 in the file). Note that the islands are visible in the orthophoto throught three "holes" in the pond polygon.

pond = shaperead('concord_hydro_area.shp', 'RecordNumbers', 14);
mapshow(pond, 'FaceColor', [0.3 0.5 1], 'EdgeColor', 'black')

Overlay road vector data in the same figure.

mapshow('concord_roads.shp', 'Color', 'red', 'LineWidth', 1);

Read SDTS DEM terrain data for Mount Washington.

[Z, R] = sdtsdemread('9129CATD.DDF');

View the terrain data as a mesh.

figure
mapshow(Z, R, 'DisplayType', 'mesh');
demcmap(Z)

View the terrain data as a surface.

figure
mapshow(Z, R, 'DisplayType', 'surface');
demcmap(Z)

View the terrain data as a 3-D surface.

view(3);
axis normal

Read the terrain data files for Mount Washington and Mount Dartmouth.

[Z_W, R_W] = arcgridread('MtWashington-ft.grd');
[Z_D, R_D] = arcgridread('MountDartmouth-ft.grd');

Display the terrain data as a surface in the z == 0 plane, so that overlying contour lines and labels are visible.

figure
hold on
mapshow(zeros(size(Z_W)),R_W,'CData',Z_W,'DisplayType','surface')
mapshow(zeros(size(Z_D)),R_D,'CData',Z_D,'DisplayType','surface')
axis equal

Overlay black contour lines and labels.

cW = mapshow(Z_W, R_W, 'DisplayType', 'contour', ...
   'LineColor','black', 'ShowText', 'on');
cD = mapshow(Z_D, R_D, 'DisplayType', 'contour', ...
   'LineColor','black', 'ShowText', 'on');

Set the colormap appropriate to terrain elevation.

demcmap(Z_W)

Tips

  • 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.

  • If s is a geostruct (has Lat and Lon fields), it may be more appropriate to use geoshow to display them. You can project latitude and longitude coordinate values to map coordinates by displaying with geoshow on a map axes.

Introduced before R2006a

Was this topic helpful?