www.gusucode.com > map 案例源码 matlab代码程序 > map/LinkLineSegmentsIntoPolygonsUsingThePolymergeFunctionExample.m
%% Link Line Segments into Polygons Using the polymerge Function %% % This example shows how to link line segments into polygons using the % |polymerge| function. |polymerge| links sets of line segments together by % concatenating segments that have matching endpoints. An end point can % be either the first or last vertex in a given part. The |polymerge| % function compares endpoints of segments within latitude and longitude % vectors to identify endpoints that match exactly or lie within a % specified distance. The matching segments are then concatenated, and the % process continues until no more coincidental endpoints can be found. For % more information, see the <docid:map_ref.f14-630977> reference page. %% % Construct column vectors representing coordinate values. The vectors use % |NaN| separators to define four line segments. % Copyright 2015 The MathWorks, Inc. lat = [3 2 NaN 1 2 NaN 5 6 NaN 3 4]'; lon = [13 12 NaN 11 12 NaN 15 16 NaN 13 14]'; %% % Concatenate the segments with matching endpoints. Three of the line % segments have overlapping end points, so |polymerge| returns two line % segments. [latm, lonm] = polymerge(lat,lon)