
		% load cosatline array.
		% load /home/roj/utils/matlab_utils/matlab_mapping/private/m_coasts.mat

		fid=fopen('Coastline_source.txt','r');
		ncst=fscanf(fid,'%f \t %f \n',[2 99999]);
		ncst=ncst';

		MISR_lat = 89.5:-1:-89.5;
		MISR_lon = -179.5:1:179.5;
		
		threshold=0.5+1E-6;

			% 
			% add points to coastline segments longer than 1/2 threhold
			%
			n_points = length(ncst(:,1));
			new_points = 0;
			count = 1;
			while count<(n_points-1+new_points)
			
				dist = abs(ncst(count,2)-ncst(count+1,2)) + abs(ncst(count,1)-ncst(count+1,1));
				if(dist>0.5*threshold)				
		
					n = floor(dist / threshold) + 1 ;
					clear new
					new(:,2) = ncst(count,2) + (1:n)/(n+1) * ( ncst(count+1,2) - ncst(count,2) );
					new(:,1) = ncst(count,1) + (1:n)/(n+1) * ( ncst(count+1,1) - ncst(count,1) );
		
					dummy1=ncst(1:count,:);

					dummy2=ncst(count+1:end,:);

					ncst = [ dummy1 ;  new ; dummy2];
				
					new_points = new_points + n  ;

					count = count +  n  ;
				end

				count = count +1;
			end


		Roj_Coastline_Mask =zeros(length(MISR_lon),length(MISR_lat));
		for i=1:length(MISR_lat(:))
			i 
			dist_lat = abs(ncst(:,2)-MISR_lat(i)) ;		
		for j=1:length(MISR_lon(:))

			dist_lon = abs(ncst(:,1)-MISR_lon(j)) ;

			a=find(dist_lat < 2*threshold & dist_lon < 2*threshold);

			if(~isempty(a))
				Roj_Coastline_Mask(j,i) = 1.0;
			end

		end
		end


		% make image of results
		fh = figure('PaperPosition',[1 1 7 6],'Visible','on');
		
			make_fig_global_latlon(MISR_lon,MISR_lat,Roj_Coastline_Mask','Roj''s Coast Line Mask',[0 0.5 1]);	
			axis([-150.6364  -39.4900   49.2940   79.8600])

	return


	%
	% junk to output data for Catherine ...
	%

	%	fid=fopen('Coastline_source.txt','w');
	%	fprintf(fid,'%f \t %f \n',ncst')

	%	matlab_put_NetCDF_data('./Roj_Coastline_Mask.nc','Roj_Coastline_Mask',Roj_Coastline_Mask,'lon','lat');

	%	hdf5write('RojCoastlineMask.hdf','RojCoastlineMask',Roj_Coastline_Mask)

	%	R = int8(Roj_Coastline_Mask);
	%	fid=fopen('RojCoastlineMask.bin','w');
	%	fwrite(fid,R,'integer*1'),


		

