function [top_lat, top_lon, topog] = decimate_topo(top_lat, ...
                                         top_lon, topog, maxpts)
% function [top_lat, top_lon, topog] = decimate_topo(top_lat, ...
%                                         top_lon, topog, maxpts)
%
% m_map has a hard time with big ranges in topography: trim the sizes a bit

%JH: 99/08/27; EF: modified 00/09/25
									 
disp(sprintf('original size of  topography is lat:%d x lon:%d\n',...
	length(top_lat),length(top_lon)))
%now subsample extracted topography so it will plot in matlab
%let's just make sure they are always fewer than 80pts in each direction
%remember: it's a vector, so lat comes first, lon comes second
skip=ceil([length(top_lat) length(top_lon)]/maxpts);
if (skip(1)>0)       %latitude
  disp('decimating latitude')
  latindex=[1:skip(1):length(top_lat)];
else
  latindex=[1:length(top_lat)];
end
if (skip(2)>0)   %longitude
  disp('decimating longitude')
  lonindex=[1:skip(2):length(top_lon)];
else
  lonindex=[1:length(top_lon)];
end
%now do the decimation
top_lat=top_lat(latindex);
top_lon=top_lon(lonindex);
topog=topog(latindex,lonindex);
disp(sprintf('decimated size of  topography is lat:%d x lon:%d\n',...
   length(top_lat),length(top_lon)))
%%% end of topography trimming

