www.gusucode.com > map 案例源码 matlab代码程序 > map/ReadAndDisplayAfricaAsGreenPolygonExample.m

    %% Read GSHHS Dataset Using an Index
%
%%
% Read the entire coarse data set, creating an index. The example uses a
% coarse data set because the toolbox includes a sample coarse data set in
% the |toolbox/map/mapdata| folder. You can use similar code to read
% intermediate, full-resolution, or high resolution GSHHS data sets.

% Copyright 2015 The MathWorks, Inc.

filename = gunzip('gshhs_c.b.gz', tempdir);
indexname = gshhs(filename{1}, 'createindex');
%%
% Display Africa as a green polygon. Note that |gshhs| detects and uses the
% index file automatically.
figure
worldmap Africa
projection = gcm;
latlim = projection.maplatlimit;
lonlim = projection.maplonlimit;
africa = gshhs(filename{1}, latlim, lonlim);
delete(filename{1})
delete(indexname)
%%
% Sort by descending level to keep smaller level 2 and level 3 features on
% top.
[~,ix] = sort([africa.Level],'descend');
africa = africa(ix);
geoshow(africa, 'FaceColor', 'green')
setm(gca, 'FFaceColor', 'cyan')