Mapping Toolbox | ![]() ![]() |
Merging Line Segments
A common operation on sets of line segments is the merging of segments that have matching ends. The polymerge
command takes latitude and longitude vectors and compares the endpoints of the segments to see which have endpoints that match exactly or to some tolerance. The matching segments are then combined until no more matching segments are found:
lat = [3 2 NaN 1 2 NaN 5 6 NaN 3 4]' ; lon = [13 12 NaN 11 12 NaN 15 16 NaN 13 14]' ; [latm,lonm] = polymerge(lat,lon); [latm lonm] ans = 5 15 6 16 NaN NaN 1 11 2 12 2 12 3 13 3 13 4 14
![]() | Extracting Polygon or Line Segments | Creating Vector Data | ![]() |