Documentation of fill_landmap


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

hh = fill_landmap ( lev , colr ) ;

Help text


  hh = fill_landmap ( lev , colr ) ;

  This function shades the continents within the existing
  map frame.  

  The input 'lev' may be 'over', 'under', 'o', 'u', or a
  scalar indicating the z-level that the map should be drawn
  at.


Cross-Reference Information

This function calls This function is called by

Listing of function fill_landmap

function hh = fill_landmap ( lev , colr ) ;

%  Get global variables used to control graphics
%  global x_coasts y_coasts
  load coast;

%  fill in the bottom of Antartica
  tem = find(isnan(long)); 
  tem = tem(1);

%  OK, this is a major hack, but it works when you shrink the
%  data to every fifth point (on line 59)

  nskip = 1;

  long2 = [NaN; ...
           long(1)*ones(5,1); long(1:(tem-1)); 180*ones(15,1); ...
           [180:-1:long(1)]'; ...
           long(tem:length(long))];
  lat2 = [NaN; ...
          [-89.9:(6.07/5):(lat(1)-6.07/5)]'; ...
          lat(1:(tem-1)); lat(tem-1)*ones(5,1); ...
          [(lat(1)-6.07/5):-(6.07/5):-89.9]'; -89.9*ones(366,1); ...
          lat(tem:length(long))];
  
  %  Set defaults
  if nargin < 2; colr = 0.7; end;
  if nargin < 1; lev = 'under'; end;
  
  if ~isstr(colr);
    if isscalar(colr); colr = colr*[1 1 1]; end;
  end

  x_coasts = [long2']; y_coasts = [lat2'];

  if isstr(lev);
    child = get(gca, 'Children');
    plotlev = [0 0];
    for i = 1:length(child);
      zd = get(child(i), 'ZData');
      plotlev(1) = max([plotlev(1); zd(:)]);
      plotlev(2) = min([plotlev(2); zd(:)]);
    end
    if strcmp(lev(1), 'o');
      lev = plotlev(1)+1;
    elseif strcmp(lev(1), 'u');
      lev = plotlev(2)-1;
    else
      error('lev must be over, under, or a number');
    end
  end

  nans = find(isnan(x_coasts));
  xc2 = [];
  yc2 = [];
  for i = 2:length(nans);
    ind = (nans(i-1)+1):nskip:(nans(i)-1);
    if length(ind) > 2;
      xc2 = [xc2 NaN x_coasts(ind)];
      yc2 = [yc2 NaN y_coasts(ind)];
    end
  end

%  Require the plot held - though with patchm, it shouldn't matter
  holdstate = ishold;
  hold on;

%  Get existing lon and lat limits
  xl=getm(gca,'maplonlimit'); yl=getm(gca,'maplatlimit');
  x0=xl(1); x1=xl(2); y0=yl(1); y1=yl(2);

%  Redefine x and y, the outlines of the continents
  x = []; y = [];
  nt1 = floor((x0+180)/360); nt2 = floor((x1+180-1.e-9)/360);
  for it = nt1:nt2;
    xtmp=xc2+it*360; ytmp=yc2;
    [tem1, tem2] = maptrimp2(ytmp, xtmp, yl, xl);
    x = [ x; nan; tem2 ]; y = [ y; nan; tem1 ];
    nans = find(isnan(x));
    ind = nans(find(diff(nans)==1)+1);
    lx = 1:length(x);
    x = x(~ismember(lx, ind)); y = y(~ismember(lx, ind));
  end;

%  Set level 

y = [y; NaN]; x = [x; NaN]; 
%  Make patches
  h=patchm(y,x,lev,0.15*[1 1 1]);

%  Set edges to white -- I can't quite figure out how to get rid of the 
%  nasty lines on the screen if you sent the edgecolor to black.
%  Any suggestions?
  set(h, 'EdgeColor', colr, 'FaceColor', colr);

%  Get rid of hold, if needed
  if ~ishold;
    hold off;
  end

%  Set output argument
  if nargout==1; hh=h; end