wmline
Display geographic line on web map
Description
wmline(
displays
the line overlay on the web map specified by the web map handle, wm
,___)wm
.
wmline(___,
specifies
name-value pairs that set additional display properties.Name,Value
)
returns
a handle to line overlay.h
= wmline(___)
Examples
Display Line on Web Map
Import a shapefile containing the coordinates of world cities as a geospatial table. Create a subtable containing the rows for London and Paris.
cities = readgeotable("worldcities.shp"); rows = cities.Name == "London" | cities.Name == "Paris"; londonParis = cities(rows,:);
Display a line from London to Paris on a web map.
wmline(londonParis)
Display Reduced Line on Web Map
Large data sets can sometimes be slow to display, making the web map appear to hang. To work around this issue, reduce the size of the data set using the reducem
function before calling wmline
.
Load vector data representing the coordinates of coastlines.
load coastlines
Reduce the number of points in the latitude and longitude vectors using the reducem
function.
[lat,lon] = reducem(coastlat,coastlon);
Create a web map that does not wrap because the data is of global extent.
webmap("Ocean Basemap","WrapAround",false)
Display the coastlines on the web map. The figure shows the description balloon that appears when you click on the line. Name the feature using the FeatureName
name-value argument.
wmline(lat,lon,"LineWidth",3,"FeatureName","coastline") wmzoom(3)
Display Circles on Web Map
Define the latitude and longitude of the feature. This example shows how to display lines on a web map that represent range data for an airport approach pattern.
lat0 = 51.50487; lon0 = 0.05235;
Create a web map and specify a base layer.
webmap('OpenStreetMap')
Compute a small circle with a 1000 meter radius. Setting the az
parameter to an empty matrix causes scircle1
to compute a complete circle.
radius = 1000; az = []; e = wgs84Ellipsoid; [lat,lon] = scircle1(lat0,lon0,radius,az,e);
Display a red circle with 1000 meter radius, using the latitude and longitude values returned by scircle1
in the previous step.
wmline(lat,lon,'Color','red','OverlayName','1000 Meters')
Compute another small circle, this time with a 2000 meter radius.
radius = 2000; [lat,lon] = scircle1(lat0,lon0,radius,az,e);
Draw the 2000 meter radius circle on the web map, setting the color to black.
wmline(lat,lon,'Color','k','OverlayName','2000 Meters')
Input Arguments
lat
— Latitudes of vertices
matrix
Latitudes of vertices, specified as a matrix.
Data Types: single
| double
lon
— Longitudes of vertices
matrix
Longitudes of vertices, specified as a matrix.
Data Types: single
| double
P
— Geographic features
geospatial table | geopoint
vector | geoshape
vector
Geographic features, specified as one of the following:
A geospatial table containing
geopointshape
,geolineshape
, orgeopolyshape
objects. Thewmline
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
geopoint
vector.A
geoshape
vector.
If P
is a geospatial table containing
geopointshape
objects or a geopoint
vector, then the overlay contains a single line connecting the
vertices.
If P
is a geospatial table containing
geolineshape
or geopolyshape
objects,
or a geoshape
vector, then the overlay contains one line
feature for each feature of P
.
wm
— Web map
web map handle
Web map, specified as a web map handle.1
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: wmline(lat,lon,'OverlayName','Shortest Route');
Autofit
— Overlay visibility
true (default) | false
Overlay visibility, specified as the comma-separated pair consisting
of 'Autofit'
and the scalar logical or numeric
value true
(1
) or false
(0
).
If
true
,wmline
adjusts the spatial extent of the map to ensure that all the vector overlays on the map are visible.If
false
,wmline
does not adjust the spatial extent when this vector layer is added to the map.
Data Types: double
| logical
Description
— Description of feature
empty character vector (''
) (default) | character vector | cell array of character vectors | scalar structure
Description of feature, specified as the comma-separated pair
consisting of 'Description'
and a character vector,
cell array of character vectors, or a scalar structure. The description
defines the content of the description balloon displayed when you
click the feature in a web map. Description elements can be either
plain text or HTML markup. When an attribute spec is provided, the
display in the balloon for the attribute fields of P
are
modified according to the specification.
If you specify a scalar cell array,
wmline
applies the value to all line features.If you specify a nonscalar cell array, the cell array must contain a value for each feature, that is, the cell array must be the same length as
P
.If the value is a structure,
wmline
applies the attribute specification to each line.
Data Types: char
| struct
| cell
OverlayName
— Name of overlay layer
'Line Overlay N
'
, (default) | character vector
N
'Name of overlay layer, specified as the comma-separated pair consisting of
'OverlayName'
and a character vector.
wmline
inserts the name in the Layer Manager
under the "Overlays" item. The Layer Manager is the tool that appears on
the right side of the web map. The default name is 'Line
Overlay
where
N
'N
is the number assigned to this
overlay.
Data Types: char
FeatureName
— Name of feature
'OverlayName
:
Line K
'
(default) | character vector | cell array of character vectors
OverlayName
:
Line K
'Name of feature, specified as the comma-separated pair consisting
of 'FeatureName'
and character vector or cell array
of character vectors. The name appears in the balloon that displays
when you click the feature in the web map. The default value is '
, where OverlayName
:
Line K
'OverlayName
is
the name of the overlay and K
is the number
assigned to the particular line.
If the value is a character vector, it applies to all features.
If the value is a cell array of character vectors, it must be either a scalar or the same length as
P
.
Data Types: char
| cell
Color
— Line color
'black'
(default) | color name | RGB triplet | cell array of color names | string vector of color names | matrix of RGB triplets
Line color, specified as the comma-separated pair consisting of
'Color'
and one of these options.
A color name such as
'red'
or a short name such as'r'
.An RGB triplet, which is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
; for example,[0.4 0.6 0.7]
.A cell array of color names such as
{'red','green','blue'}
or{'r','g','b'}
.A string vector of color names such as
["red" "green" "blue"]
or["r" "g" "b"]
.A matrix of RGB triplets, which is a three-column matrix in which each row is an RGB triplet.
The way you specify the color depends on the desired color scheme.
To apply the same color to all lines in
P
, specify a single color name or RGB triplet.To apply a different color to each line in
P
, specify a cell array of color names, a string vector of color names, or a matrix of RGB triplets. The number of colors and RGB triplets must match the length ofP
.
This table contains the color names and equivalent RGB triplets for some common colors.
Color Name | Short Name | RGB Triplet | Appearance |
---|---|---|---|
"red" | "r" | [1 0 0] |
|
"green" | "g" | [0 1 0] |
|
"blue" | "b" | [0 0 1] |
|
"cyan"
| "c" | [0 1 1] |
|
"magenta" | "m" | [1 0 1] |
|
"yellow" | "y" | [1 1 0] |
|
"black" | "k" | [0 0 0] |
|
"white" | "w" | [1 1 1] |
|
Data Types: char
| string
| cell
| double
LineWidth
— Width of line in pixels
1 (default) | positive numeric scalar or vector
Width of line in pixels, specified as the comma-separated pair
consisting of LineWidth
and a positive numeric
scalar or vector. If you specify a vector, it must include a value
for each line, that is, the vector must be the same length as P
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Alpha
— Transparency of line
1 (default) | numeric scalar or vector
Transparency of line, specified as the comma-separated pair
consisting of 'Alpha'
and a numeric scalar or vector.
If you specify a vector, it must include a value for each line, that
is, the vector must be the same length as P
.
The default value, 1
, means that the line is fully
opaque.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
h
— Overlay layer
handle to line overlay
Overlay layer, returned as a handle to a line overlay.
Tips
Under certain conditions, when you zoom in on a line overlay in a web map, parts of the line may become invisible. This can occur if the data is one long line segment that is composed of many parts. To work around this issue, break the long line into a series of line segments by inserting
NaN
values in the line data.
Version History
Introduced in R2013bR2021b: Display data from geospatial tables
The wmline
function accepts geospatial tables as
input.
1 Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.
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 (한국어)