polymerge - Merge line segments with matching endpoints

Syntax

[lat2,lonc2 = polymerge(lat,lon)
[lat2,lonc2 = polymerge(lat,lon,tol)
[lat2,lonc2 = polymerge(lat,lon,tol,outputformat)

[lat2,lonc2 = polymerge(lat,lon) combines vector line segments with identical endpoints. polymerge compares the endpoints of all line segments and combines those that match. The line can be input as vectors of latitude and longitude with NaNs delimiting segments. The line can 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 NaNs 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 =
    14    14
    13    13
    12    12
    12    12
    11    11
    10    10
     9     9
     9     9
     8     8
     7     7
     6     6
     6     6
     5     5
     4     4
     3     3
     3     3
     2     2
     1     1

See Also

polybool, polyjoin, polysplit

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS