function xout=spread(x,nrng)
% spread data up to nrng cells away
% -Inf for land;  Inf for fill
[m,n]=size(x);
xout=x;
for range=1:nrng,
 idata=find(finite(xout));
 ii=find(xout(idata+1)==Inf);
 xout(idata(ii)+1)=xout(idata(ii));
% xout(idata(ii)+2)=xout(idata(ii));
 ii=find(xout(idata-1)==Inf);
 xout(idata(ii)-1)=xout(idata(ii));
% xout(idata(ii)-2)=xout(idata(ii));
 ii=find(xout(idata-m)==Inf);
 xout(idata(ii)-m)=xout(idata(ii));
 ii=find(xout(idata+m)==Inf);
 xout(idata(ii)+m)=xout(idata(ii));
end
igaps=find(xout==Inf);
if(~isempty(igaps)),
  xout(igaps)=-Inf*ones(size(igaps));
end
