Mapping Toolbox | ![]() ![]() |
Merge line segments with matching endpoints.
Syntax
[lat2,lon2] = polymerge(lat,lon) [lat2,lon2] = polymerge(lat,lon,tol) [lat2,lon2] = polymerge(lat,lon,outputformat)
Description
[lat2,lonc2 = polymerge(lat,lon) combines vector line segments with identical endpoints. polymerge
compares the endpoints of all line segments and combines those which match. The line may be input as vectors of latitude and longitude with NaN
s delimiting segments. The line may also be input as cell arrays, with each element of a cell array containing a line segment. The resulting line is in the same format as the input.
[lat2,lonc2 = polymerge(lat,lon,tol) combines line segments whose endpoints are separated by less than the circular tolerance. If omitted, tol= 0
is assumed. The tolerance is in the same units as the polygon input.
[lat2,lonc2 = polymerge(lat,lon,tol,outputformat
) controls the format of the resulting polygons. If outputformat is 'vector
', the result is returned as vectors with NaN
s separating the segments. If outputformat is 'cell
', the result is returned as cell arrays containing segments in each element. If omitted, 'vector
' is assumed.
Example
lat = [1 2 3 NaN 6 7 8 9 NaN 6 5 4 3 NaN 12 13 14 NaN 9 10 11 12]'; lon = lat; [lat2,lon2] = polymerge(lat,lon); [lat2 lon2] ans = 1 1 2 2 3 3 3 3 4 4 5 5 6 6 6 6 7 7 8 8 9 9 9 9 10 10 11 11 12 12 12 12 13 13 14 14
See Also
polyjoin |
Convert polygon segments from cell array to vector format |
polysplit |
Extract segments of NaN -delimited polygon vectors to cell arrays |
![]() | polyjoin | polysplit | ![]() |