polymerge
Merge line segments with matching endpoints
Syntax
[latMerged, lonMerged] = polymerge(lat,
lon)
[latMerged, lonMerged] = polymerge(lat,
lon, tol)
[latMerged, lonMerged] = polymerge(lat,
lon, tol, outputFormat)
Description
[latMerged, lonMerged] = polymerge(lat,
lon)
accepts a multipart line in latitude-longitude with
vertices stored in arrays lat
and lon
,
and merges the parts wherever a pair of end points coincide. For this
purpose, an end point can be either the first or last vertex in a
given part. When a pair of parts are merged, they are combined into
a single part and the duplicate common vertex is removed. If two first
vertices coincide or two last vertices coincide, then the vertex order
of one of the parts will be reversed. A merge is applied anywhere
that the end points of exactly two distinct parts coincide, so that
an indefinite number of parts can be chained together in a single
call to polymerge
. If three or more distinct parts
share a common end point, however, the choice of which parts to merge
is ambiguous and therefore none of the corresponding parts are connected
at that common point.
The inputs lat
and lon
can
be column or row vectors with NaN-separated parts (and identical NaN
locations in each array), or they can be cell arrays with each part
in a separate cell. The form of the output arrays, latMerged
and lonMerged
,
matches the inputs in this regard.
[latMerged, lonMerged] = polymerge(lat,
lon, tol)
combines line segments whose endpoints are separated
by less than the circular tolerance, tol
. tol
has
the same units as the polygon input.
[latMerged, lonMerged] = polymerge(lat,
lon, tol, outputFormat)
allows you to request either the NaN-separated vector form for the output (set
outputFormat
to 'vector'
), or the cell array form (set
outputFormat
to 'cell'
).
Examples
Version History
Introduced before R2006a