


FIXCOAST Makes sure coastlines meet Signell's conventions. Usage: [coast]=fixcoast(coast) Fixes coastline is in the format we want. Assumes that lon/lat are in the first two columns of the matrix coast, and that coastline segments are separated by rows of NaNs (or -99999s). This routine ensures that only 1 row of NaNs separates each segment, and makes sure that the first and last rows contain NaNs. Rich Signell (rsignell@usgs.gov)


0001 function [coast]=fixcoast(coast) 0002 % FIXCOAST Makes sure coastlines meet Signell's conventions. 0003 % 0004 % Usage: [coast]=fixcoast(coast) 0005 % 0006 % Fixes coastline is in the format we 0007 % want. Assumes that lon/lat are in the first two columns of 0008 % the matrix coast, and that coastline segments are 0009 % separated by rows of NaNs (or -99999s). This routine ensures that 0010 % only 1 row of NaNs separates each segment, and makes 0011 % sure that the first and last rows contain NaNs. 0012 % 0013 % 0014 % Rich Signell (rsignell@usgs.gov) 0015 0016 ind=find(coast==(-99999.)); 0017 if(~isempty(ind)), 0018 coast(ind)=coast(ind)*nan; 0019 end 0020 ind=find(isnan(coast(:,1))); 0021 if(~isempty(ind)), 0022 dind=diff(ind); 0023 idup=find(dind==1); 0024 if(~isempty(idup)), 0025 coast(ind(idup),:)=[]; 0026 ind(idup)=[]; 0027 end 0028 end 0029 [m,n]=size(coast); 0030 if(~isnan(coast(1,1))), 0031 coast=[ones(1,n)*nan; coast]; 0032 end 0033 [m,n]=size(coast); 0034 if(~isnan(coast(m,1))), 0035 coast=[coast; ones(1,n)*nan]; 0036 end