Main Content

makesymbolspec

Create vector layer symbol specification

Description

symbolspec = makesymbolspec(geometry,rule1,rule2,...,ruleN) creates a symbol specification symbolspec for the shape geometry according to the rules specified in one or more rule arguments.

Use symbol specifications to customize the appearance of vector shapes for maps you create using the mapshow and geoshow functions.

example

Examples

collapse all

Import a shapefile containing road data for Concord, MA, as a geospatial table.

roads = readgeotable("concord_roads.shp");

Create a symbol specification that specifies the default line color as purple.

blueRoads = makesymbolspec("Line",{'Default','Color','#7E2F8E'});

Display the roads using the symbol specification.

mapshow(roads,"SymbolSpec",blueRoads)

Figure contains an axes object. The axes object contains 609 objects of type line.

Import a shapefile containing road data for Concord, MA, as a geospatial table.

roads = readgeotable("concord_roads.shp");

The CLASS attribute includes information about road types. For example, a value of 2 indicates a multilane highway and a value of 6 indicates a minor road. Create a symbol specification that specifies road colors based on the value of CLASS.

roadColors = makesymbolspec("Line", ...
    {'CLASS',2,'Color','#A2142F'}, ...
    {'CLASS',3,'Color','#77AC30'}, ...
    {'CLASS',6,'Color','#0072BD'}, ...
    {'Default','Color','k'});

Display the roads using the symbol specification.

mapshow(roads,"SymbolSpec",roadColors)

Figure contains an axes object. The axes object contains 609 objects of type line.

Import a shapefile containing road data for Concord, MA, as a geospatial table.

roads = readgeotable("concord_roads.shp");

The CLASS attribute includes information about road types. For example, a value of 2 indicates a multilane highway and a value of 6 indicates a minor road. Create a symbol specification that specifies line styles and widths based on the value of CLASS such that major roads have a thick dashed lines and minor roads have thin dash-dotted lines.

lineStyles = makesymbolspec("Line", ...
    {'CLASS',[1 3],'LineStyle',':','LineWidth',2}, ...
    {'CLASS',[4 6],'LineStyle','-.','LineWidth',0.25});

Display the roads using the symbol specification.

mapshow(roads,"SymbolSpec",lineStyles)

Figure contains an axes object. The axes object contains 609 objects of type line.

Import a shapefile containing road data for Concord, MA, as a geospatial table.

roads = readgeotable("concord_roads.shp");

The CLASS attribute includes information about road types. For example, a value of 2 indicates a multilane highway, a value of 3 indicates a major road, and a value of 6 indicates a minor road. Create a symbol specification that specifies line colors in the turbo colormap based on the value of CLASS so that highways are blue, major roads are green, and minor roads are red.

cmap = turbo(5);
colorRange = makesymbolspec("Line", ...
    {'CLASS',[2 6],'Color',cmap});

Display the roads using the symbol specification.

mapshow(roads,"SymbolSpec",colorRange)

Add a colorbar to the map by setting the colormap and colormap limits of the axes.

colormap(cmap)
clim([2 7])
colorbar

Figure contains an axes object. The axes object contains 609 objects of type line.

Input Arguments

collapse all

Shape type, specified as one of these options:

  • "Point" — Point shape

  • "Line" — Line shape

  • "PolyLine" — Series of connected line shapes

  • "Polygon" — Polygon shape

  • "Patch" — Patch shape

Data Types: char | string

Shape customization rule, specified as a cell array.

To create a default rule for all features with the specified geometry, specify rule using this pattern:

{'Default',Property1,Value1,Property2,Value2,...,PropertyN,ValueN},

where Property1, Property2, and PropertyN are graphics properties and Value1, Value2, and ValueN are values. Specify properties using character vectors. Valid properties depend on the value of geometry:

  • "Point" — Valid properties are Marker, Color, MarkerEdgeColor, MarkerFaceColor, MarkerSize, and Visible. For a description of each property, see Line Properties.

  • "Line" and "PolyLine" — Valid properties are Color, LineStyle, LineWidth, and Visible. For a description of each property, see Line Properties.

  • "Polygon" and "Patch" — Valid properties are FaceColor, FaceAlpha, LineStyle, LineWidth, EdgeColor, and EdgeAlpha, and Visible. For a description of each property, see Patch Properties.

To create a rule based on the values of an attribute, specify rule using this pattern:

{AttributeName,AttributeValue,Property1,Value1,Property2,Value2,...,PropertyN,ValueN},

where AttributeName is the attribute and AttributeValue is the value or range of values. The size of AttributeValue and Value1, Value2, and ValueN do not need to match.

When a feature does not match a rule, the mapshow and geoshow functions display the feature using default graphics properties.

Data Types: cell

Version History

Introduced before R2006a

See Also

Functions