NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/matlab_cen/lndfill.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 % function lndfill(landname,color)
2 function lndfill(landname,color)
3 %
4 % Set color (if not sent)
5 if nargin == 1;color=[0.8 0.8 0.8];end
6 %
7 % Load data from .lnd and .lbe files
8 load([landname,'.lnd']);x=eval([landname,'(:,2)']);y=eval([landname,'(:,3)']);
9 load([landname,'.lbe']);bel=eval([landname]);
10 %
11 % colorfill land and islands
12 hold on
13 i2=0;
14 while i2 < length(bel)
15 %
16    i1=i2+1;
17    i2=find(bel(:,3)==bel(i1,2));
18    polygon=bel(i1:i2,2);
19    xp=x(polygon);yp=y(polygon);
20    hf=fill(xp,yp,color);
21 %   set(hf,'EdgeColor',color')
22 end
23 break
24 %-----------------------------------------------------------------------
25 % Below here are the commands used to make the .lnd and .lbe files for
26 % the adrdep2kmg grid (i.e. input from the adrionA grid)
27 %-----------------------------------------------------------------------
28 load adrionA.nod;
29 x=adrionA(:,2);
30 y=adrionA(:,3);
31 load adrionA_tides.bel;
32 bel=adrionA_tides;
33 clear polygon;
34 %
35 % Outer land boundary
36 %
37 sea=find(bel(:,5)==5);
38 polygon=bel(1:sea(1),2);
39 xp=x(polygon);yp=y(polygon);
40 %
41 ni=length(xp)+1; xp(ni)=min(xp)-200000.0; yp(ni)=yp(ni-1);
42 ni=length(xp)+1; xp(ni)=xp(ni-1);         yp(ni)=max(yp)+200000.0;
43 ni=length(xp)+1; xp(ni)=max(xp)+200000.0; yp(ni)=yp(ni-1);
44 ni=length(xp)+1; xp(ni)=xp(ni-1);         yp(ni)=yp(1);
45 %
46 figure
47 hp=plot(xp,yp,'b-');
48 hold on
49 %
50 fnod=fopen('adrdep2kmg.lnd','w');
51 fbel=fopen('adrdep2kmg.lbe','w');
52 ione=1
53 for i=1:length(xp)-1
54    fprintf(fnod,'%i %f %f\n',i,xp(i),yp(i));
55    fprintf(fbel,'%i %i %i\n',i,i,i+1);
56 end
57 i=length(xp);
58 fprintf(fnod,'%i %f %f\n',i,xp(i),yp(i));
59 fprintf(fbel,'%i %i %i\n',i,i,ione);
60 %
61 % first island
62 %
63 clear polygon;
64 i1=sea(length(sea))+1
65 i2=find(bel(:,3)==bel(i1,2))
66 polygon=bel(i1:i2,2);
67 xp=x(polygon);yp=y(polygon);
68 hp=plot(xp,yp,'r-');
69 %
70 ione=i+1
71 for ii=1:length(xp)-1
72    i=i+1;
73    fprintf(fnod,'%i %f %f\n',i,xp(ii),yp(ii));
74    fprintf(fbel,'%i %i %i\n',i,i,i+1);
75 end
76 i=i+1;
77 fprintf(fnod,'%i %f %f\n',i,xp(length(xp)),yp(length(xp)));
78 fprintf(fbel,'%i %i %i\n',i,i,ione);
79 %
80 % remaining islands
81 %
82 while i2 < length(bel)
83 %
84    i1=i2+1;
85    i2=find(bel(:,3)==bel(i1,2));
86    polygon=bel(i1:i2,2);
87    xp=x(polygon);yp=y(polygon);
88    hp=plot(xp,yp,'r-');
89 %
90    ione=i+1
91    for ii=1:length(xp)-1
92       i=i+1;
93       fprintf(fnod,'%i %f %f\n',i,xp(ii),yp(ii));
94       fprintf(fbel,'%i %i %i\n',i,i,i+1);
95    end
96    i=i+1;
97    fprintf(fnod,'%i %f %f\n',i,xp(length(xp)),yp(length(xp)));
98    fprintf(fbel,'%i %i %i\n',i,i,ione);
99 end
100 fclose(fnod);
101 fclose(fbel);
102 %-----------------------------------------------------------------------
103 % Below here are the commands used to make the .lnd and .lbe files for
104 % the yessub grid (i.e. input from the yessoj grid)
105 %-----------------------------------------------------------------------
106 load yessoj.bdry.nod;
107 x=yessoj(:,2);
108 y=yessoj(:,3);
109 load yessoj.bdry.bel;
110 bel=yessoj;
111 clear polygon;
112 %
113 % Outer land boundary
114 %
115 sea=find(bel(:,5)==2);
116 polygon=bel(1:sea(1)-1,2);
117 xp=x(polygon);yp=y(polygon);
118 %
119 ni=length(xp)+1; xp(ni)=min(xp)-200000.0; yp(ni)=yp(ni-1);
120 ni=length(xp)+1; xp(ni)=xp(ni-1);         yp(ni)=max(yp)+200000.0;
121 ni=length(xp)+1; xp(ni)=max(xp)+200000.0; yp(ni)=yp(ni-1);
122 ni=length(xp)+1; xp(ni)=xp(ni-1);         yp(ni)=min(yp)-200000.0;
123 ni=length(xp)+1; xp(ni)=xp(1)-200000.0; yp(ni)=yp(ni-1);
124 ni=length(xp)+1; xp(ni)=xp(1)-200000.0;   yp(ni)=yp(1);
125 %
126 figure
127 hp=plot(xp,yp,'b-');
128 hold on
129 %
130 fnod=fopen('yessoj.lnd','w');
131 fbel=fopen('yessoj.lbe','w');
132 ione=1
133 for i=1:length(xp)-1
134    fprintf(fnod,'%i %f %f\n',i,xp(i),yp(i));
135    fprintf(fbel,'%i %i %i\n',i,i,i+1);
136 end
137 i=length(xp);
138 fprintf(fnod,'%i %f %f\n',i,xp(i),yp(i));
139 fprintf(fbel,'%i %i %i\n',i,i,ione);
140 %
141 % first island
142 %
143 clear polygon;
144 i1=sea(1)
145 i2=find(bel(:,3)==bel(i1,2))
146 polygon=bel(i1:i2,2);
147 xp=x(polygon);yp=y(polygon);
148 hp=plot(xp,yp,'r-');
149 %
150 ione=i+1
151 for ii=1:length(xp)-1
152    i=i+1;
153    fprintf(fnod,'%i %f %f\n',i,xp(ii),yp(ii));
154    fprintf(fbel,'%i %i %i\n',i,i,i+1);
155 end
156 i=i+1;
157 fprintf(fnod,'%i %f %f\n',i,xp(length(xp)),yp(length(xp)));
158 fprintf(fbel,'%i %i %i\n',i,i,ione);
159 %
160 % remaining islands
161 %
162 while i2 < length(bel)
163 %
164    i1=i2+1;
165    i2=find(bel(:,3)==bel(i1,2));
166    polygon=bel(i1:i2,2);
167    xp=x(polygon);yp=y(polygon);
168    hp=plot(xp,yp,'r-');
169 %
170    ione=i+1
171    for ii=1:length(xp)-1
172       i=i+1;
173       fprintf(fnod,'%i %f %f\n',i,xp(ii),yp(ii));
174       fprintf(fbel,'%i %i %i\n',i,i,i+1);
175    end
176    i=i+1;
177    fprintf(fnod,'%i %f %f\n',i,xp(length(xp)),yp(length(xp)));
178    fprintf(fbel,'%i %i %i\n',i,i,ione);
179 end
180 fclose(fnod);
181 fclose(fbel);
Note: See TracBrowser for help on using the browser.