mapshow

Display map data without projection

Description

example

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 the geographic data structure S as points, multipoints, lines, or polygons according to the 'Geometry' field of S.

  • If S contains 'X' and 'Y' fields, then these fields are used directly to plot features in map coordinates.

  • If S contains 'Lat' and 'Lon' fields, then the coordinates are projected with the Plate Carrée projection and a warning is issued.

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.

example

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

example

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

example

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.

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 through 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)

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 a geographic data structure or dynamic vector.

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.

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

Matrix

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.

FormatDisplayType
Shape file'point', 'multipoint', '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)

Data Types: char | scalar

Parent axes, specified as an axes object.

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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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
'line'line
'polygon'patch
Image'image'surface
Grid'surface'surface
'mesh'surface
'texturemap'surface
'contour'contour

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

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