1 | function m_gshhs(resolution,varargin); |
---|
2 | % M_GSHHS Add a coastline to a given map using |
---|
3 | % the Global Self-consistant Hierarchical High-resolution |
---|
4 | % Shorelines, Rivers, and Borders |
---|
5 | % |
---|
6 | % M_GSHHS(RES, (standard line option,...,...) ) draws the coastline |
---|
7 | % river network, or borders as simple lines. |
---|
8 | % |
---|
9 | % M_GSHHS(RES,'patch' ( ,standard patch options,...,...) ) draws the |
---|
10 | % coastline as a number of patches (rivers and borders are not |
---|
11 | % arranged so patches can be drawn). |
---|
12 | % |
---|
13 | % M_GSHHS(RES,'save',FILENAME) saves the extracted coastline data |
---|
14 | % for the current projection in a file FILENAME. This allows |
---|
15 | % speedier replotting using M_USERCOAST(FILENAME). |
---|
16 | % |
---|
17 | % RES: A two-char string (optionally 1) |
---|
18 | % |
---|
19 | % First char: resolution - one of |
---|
20 | % 'c' crude |
---|
21 | % 'l' low |
---|
22 | % 'i' intermediate |
---|
23 | % 'h' high |
---|
24 | % 'f' full |
---|
25 | % |
---|
26 | % Second char: type - one of |
---|
27 | % 'c' GSHHS coastline (default) |
---|
28 | % 'b' WDB Border |
---|
29 | % 'r' WDB River |
---|
30 | % |
---|
31 | % (also maintained is this optional format: |
---|
32 | % |
---|
33 | % RES - selections resolution |
---|
34 | % 1 or 'crude' |
---|
35 | % 2 or 'low' |
---|
36 | % 3 or 'intermediate' |
---|
37 | % 4 or 'high' |
---|
38 | % 5 or 'full |
---|
39 | % |
---|
40 | % but please don't use this). |
---|
41 | % |
---|
42 | % See also M_PROJ, M_GRID, M_COAST, M_GSHHS_L, M_GSHHS_H, M_GSHHS_C |
---|
43 | % M_USERCOAST |
---|
44 | |
---|
45 | % Rich Pawlowicz (rich@ocgy.ubc.ca) 15/June/98 |
---|
46 | % |
---|
47 | % |
---|
48 | % This software is provided "as is" without warranty of any kind. But |
---|
49 | % it's mine, so you can't sell it. |
---|
50 | % |
---|
51 | % 16/Dec/2005 |
---|
52 | %********************************************************************* |
---|
53 | % Modified after code provided by Bruce Lipphardt (brucel@udel.edu) to |
---|
54 | % reduce the hierarchy of M_GSHHS_* routines to a single routine with a |
---|
55 | % variable resolution input: |
---|
56 | % 20/Jan/2008 - added borders and rivers from gshhs v1.10 |
---|
57 | |
---|
58 | % Root of directories where gshhs_X.b files live |
---|
59 | FILNAME='private/'; |
---|
60 | |
---|
61 | |
---|
62 | res_list = char('c','l','i','h','f') ; |
---|
63 | typ_list=char('c','b','r'); |
---|
64 | typ_names={'gshhs_','wdb_borders_','wdb_rivers_'}; |
---|
65 | |
---|
66 | typ=1; |
---|
67 | if isstr(resolution), |
---|
68 | if length(resolution)>=2, |
---|
69 | typ = strmatch(lower(resolution(2)),typ_list); |
---|
70 | end; |
---|
71 | resolution = strmatch(lower(resolution(1)),res_list); |
---|
72 | end; |
---|
73 | |
---|
74 | |
---|
75 | if isempty(resolution) | resolution<1 | resolution> length(res_list), |
---|
76 | error('**Don''t recognize the specified resolution'); |
---|
77 | end; |
---|
78 | if isempty(typ) | typ<1 | typ> length(res_list), |
---|
79 | error('**Don''t recognize the specified type'); |
---|
80 | end; |
---|
81 | |
---|
82 | res_char = res_list(resolution) ; |
---|
83 | file = [FILNAME,sprintf('%s%s.b',typ_names{typ},res_char)] ; |
---|
84 | tag_name = sprintf('%s%s',typ_names{typ},res_char) ; |
---|
85 | |
---|
86 | |
---|
87 | % Set current projection to geographic |
---|
88 | Currentmap=m_coord('set'); |
---|
89 | m_coord('geographic'); |
---|
90 | |
---|
91 | |
---|
92 | if length(varargin)>1 & strcmp(varargin{1},'save'), |
---|
93 | [ncst,Area,k]=mu_coast(res_char,file); |
---|
94 | eval(['save ' varargin{2} ' ncst k Area']); |
---|
95 | else |
---|
96 | mu_coast(res_char,file,varargin{:},'tag',tag_name); |
---|
97 | end; |
---|
98 | |
---|
99 | m_coord(Currentmap.name); |
---|
100 | |
---|