function land=isonland2(lon,lat,altitude);

% function land=isonland2(lon,lat,altitude);
%
%  given a vector or matrix of lons and lats, 
%   this routine returns 1 for points at
%   altitude > "altitude", and 0 for points
%   at lower altitudes.  Default is 0 (sea level).

if ~exist('altitude')
    altitude=0;
end;

load bathyworld
if (max(max(lon))>=180)
    q=find(lon2<0);
    lon3=lon2(q)+360;
    lon2=[lon2,lon3];
    z2=[z2,z2(:,q)];
end;

q=find(z2>altitude);
z2(q)=1e6;
q=find(z2<altitude);
z2(q)=-1e6;

if (  (size(lat,1)>1 & size(lat,2)>1)  | ...
        (length(lat)~=length(lon))  );
    land=interp2(lon2,lat2',z2,lon,lat','linear');
else % lat and lon are vectors of equal length: return vector
    land=interp2(lon2,lat2',z2,lon,lat,'linear');
end;
q=find(land>0);
land(q)=1;
q=find(land<0);
land(q)=0;
