makesymbolspec
Create vector layer symbol specification
Description
symbolspec = makesymbolspec(
creates a symbol specification geometry
,rule
1,rule
2,...,rule
N)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.
Examples
Specify Default Line Color
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)
Specify Line Color Based on Attribute Values
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)
Specify Line Style Using Range of Attribute Values
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)
Specify Line Style Using Range of Attribute and Property Values
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
Input Arguments
geometry
— Shape type
"Point"
| "Line"
| "PolyLine"
| "Polygon"
| "Patch"
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
rule
— Shape customization rule
cell array
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 areMarker
,Color
,MarkerEdgeColor
,MarkerFaceColor
,MarkerSize
, andVisible
. For a description of each property, see Line Properties."Line"
and"PolyLine"
— Valid properties areColor
,LineStyle
,LineWidth
, andVisible
. For a description of each property, see Line Properties."Polygon"
and"Patch"
— Valid properties areFaceColor
,FaceAlpha
,LineStyle
,LineWidth
,EdgeColor
, andEdgeAlpha
, andVisible
. 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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)