www.gusucode.com > map 案例源码 matlab代码程序 > map/ClosePolygonInLatLonCoordinatesExample.m
%% Close Polygon in Latitude-Longitude Coordinates % %% % Load coastline data from MAT-file. % Copyright 2015 The MathWorks, Inc. load coastlines %% % Construct a two-part polygon based on the coastlines data. The first % ring is Antarctica. The longitude of its first vertex is -180 and the % longitude of its last vertex is 180. The second ring is a small island % from which the last vertex, a replica of the first vertex, is removed. [latparts, lonparts] = polysplit(coastlat, coastlon); latparts{2}(end) = []; lonparts{2}(end) = []; latparts(3:end) = []; lonparts(3:end) = []; [lat, lon] = polyjoin(latparts, lonparts); %% % Examine how |closePolygonParts| treats the two rings. In both cases, the % first and last vertices differ. However, Antarctica remains unchanged % while the small island is closed back up. [latClosed, lonClosed] = closePolygonParts(lat, lon, 'degrees'); [latpartsClosed, lonpartsClosed] = polysplit(latClosed, lonClosed); lonpartsClosed{1}(end) - lonpartsClosed{1}(1) % Result is 360 lonpartsClosed{2}(end) - lonpartsClosed{2}(1) % Result is 0