-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoastall3.m
More file actions
69 lines (64 loc) · 1.91 KB
/
coastall3.m
File metadata and controls
69 lines (64 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function coastall(linetype,filename,axislim,subplt)
% function coastall(linetype,filename,axislim,subplt)
% All inputs are optional.
% Script tool to plot coastline on current plot if there one.
% Otherwise, it draws with axis limits
% axislim=[longwest longeast latsouth latorth]
% Data comes from a file like 'coastisl.dat' (global med-resolution)
% with format: segments # -999, followed by # lat long pairs.
% Routine must read entire file (relatively slow, but memory saving).
% Assumes longitude axis -180 to 180
% linetype '-w' default.
% 15 Dec 1993 G.Lagerloef
% Modified March 1995 R.Dewey
% again 6/96 to make aspect ratio correct (km in x == km in y)
if nargin<1, linetype='-k'; end % black now k
if nargin<2, filename='coastisl.dat'; end
if nargin<4, subplt=[1 1 1]; end
h=subplot(subplt(1),subplt(2),subplt(3));set(h,'Visible','off');
[fid,msg]=fopen(filename);
if ~isempty(msg), error(msg), end
xlim=get(gca,'XLim');
if xlim == [0 1], % no figure yet.
if nargin < 3
xlim=[-180 180];
ylim=[-90 90];
else
xlim=[axislim(1) axislim(2)];
ylim=[axislim(3) axislim(4)];
end
else
ylim=get(gca,'YLim');
end
xmid=mean(xlim);ymid=mean(ylim);
dlat=abs(ylim(2)-ylim(1));
dlong=abs(xlim(2)-xlim(1));
dsx=gcdist(ymid,xmid,ymid,xmid+1.0)*dlong;
dsy=gcdist(ymid-0.5,xmid,ymid+0.5,xmid)*dlat;
ratio=abs(dsx/dsy); % this is the ratio of km in long vs lat.
%
set(gca,'Box','on');
xneg=1;
if xlim(1) < 0 & xlim(2) <= 0,
xlim=abs(xlim);
axis([xlim(2) xlim(1) ylim(1) ylim(2)]);
set(gca,'XDir','reverse');
xneg=-1;
else
axis([xlim(1) xlim(2) ylim(1) ylim(2)]);
end
%
fbox; % draw nice box around figure
axis(axis);
hold on;
%
count=1;
while count,
a=fscanf(fid,'%f',2);
if isempty(a), fclose(fid); return, end
b=fscanf(fid,'%f',[2,a(1)]);
plot(xneg*b(2,:),b(1,:),linetype),
end
fclose(fid);
%
% fini