Home > atmlab > geoplots > coastlines.m

coastlines

PURPOSE ^

COASTLINES Adds coast lines to your plot.

SYNOPSIS ^

function coastlines(varargin)

DESCRIPTION ^

 COASTLINES   Adds coast lines to your plot.

    The resolution is on the 1 degree level. Thus only suitable for global 
    plots.

    Note that this function will affect the color map and a colorbar should
    be placed before calling this function.

    The optional argument *lonrange* can be used when a longitude range
    different from [0 360] is used.

    Uses the topo.mat file from the matlab demos directory.

 FORMAT   coastlines([lcolor,lwidth,lonrange])
        
 OPT   lcolor   Line color. Default is [0 0 0].
       lwidth   Line width. Default is 1.
       lonrange Lower and upper limit for output longitudes. Default
                is [0 360]. Must be a 360 degree range.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

coastlines.m

SOURCE CODE ^

0001 % COASTLINES   Adds coast lines to your plot.
0002 %
0003 %    The resolution is on the 1 degree level. Thus only suitable for global
0004 %    plots.
0005 %
0006 %    Note that this function will affect the color map and a colorbar should
0007 %    be placed before calling this function.
0008 %
0009 %    The optional argument *lonrange* can be used when a longitude range
0010 %    different from [0 360] is used.
0011 %
0012 %    Uses the topo.mat file from the matlab demos directory.
0013 %
0014 % FORMAT   coastlines([lcolor,lwidth,lonrange])
0015 %
0016 % OPT   lcolor   Line color. Default is [0 0 0].
0017 %       lwidth   Line width. Default is 1.
0018 %       lonrange Lower and upper limit for output longitudes. Default
0019 %                is [0 360]. Must be a 360 degree range.
0020 
0021 % 2006-03-27   Created by Patrick Eriksson (code from Mattias Ekstrom).
0022 
0023 
0024 function coastlines(varargin)
0025 %
0026 [lcolor,lwidth,lonrange] = optargs( varargin, { [0 0 0], 1, [0 360] } );
0027                                                                          %&%
0028                                                                          %&%
0029 if lonrange(2)-lonrange(1) ~= 360                                        %&%
0030   error('Longitude range must be 360 degrees wide.')                     %&%
0031 end                                                                      %&%
0032 
0033 
0034 load topo
0035 
0036 
0037 lons = 0.5:359.5;
0038 
0039 ind       = find( lons < lonrange(1) );
0040 lons(ind) = lons(ind)+360;
0041 ind       = find( lons > lonrange(2) );
0042 lons(ind) = lons(ind)-360;
0043 
0044 [lons,ind] = sort( lons );
0045 %
0046 topo       = topo(:,ind);
0047 
0048 
0049 contour(lons,-89.5:89.5,topo,[0 0],'LineColor',lcolor,'LineWidth',lwidth);
0050 
0051 
0052

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005