%KUSTLIDAR_PLOT_GRIDS .
%
%See also: 

clear all
close all

L.x = nc_varget('f:\opendap\thredds\deltares\landboundaries\holland.nc','x');
L.y = nc_varget('f:\opendap\thredds\deltares\landboundaries\holland.nc','y');

OPT.rawdir = 'f:\checkouts\OpenEarthRawData\rijkswaterstaat\kustlidar\raw\';
OPT.pngdir = 'f:\checkouts\OpenEarthRawData\rijkswaterstaat\kustlidar\png\';
OPT.years  = dir(OPT.rawdir);

% adf = findAllFiles(OPT.rawdir,'pattern_incl','hdr.adf'): 1439 cells

[num2str([1:length(OPT.years)]','%0.3d:') char(OPT.years.name)]

for iyear=1:length(OPT.years)  % note contents changes when images appear
if          OPT.years(iyear).isdir
if ~strcmpi(OPT.years(iyear).name,'.')  && ...
   ~strcmpi(OPT.years(iyear).name,'..') && ...
   ~strcmpi(OPT.years(iyear).name,'.svn')
   
   disp([num2str(iyear,'%0.3d'),' : ',OPT.years(iyear).name])

   OPT.sets = dir(fullfile(OPT.rawdir,OPT.years(iyear).name,'geogegevens','raster' ));

   for iset=1:length(OPT.sets)
      disp([' ',num2str(iset,'%0.3d')])
   if          OPT.sets(iset).isdir
   if ~strcmpi(OPT.sets(iset).name,'.')  && ...
      ~strcmpi(OPT.sets(iset).name,'..') && ...
      ~strcmpi(OPT.sets(iset).name,'.svn')
      
      disp([' ',num2str(iset,'%0.3d'),' : ',OPT.sets(iset).name])

      OPT.files = dir(fullfile(OPT.rawdir,OPT.years(iyear).name,'geogegevens','raster',OPT.sets(iset).name));

      for ifile=1:length(OPT.files)
         disp(['  ',num2str(ifile,'%0.3d')]);
      if          OPT.files(ifile).isdir
      if ~strcmpi(OPT.files(ifile).name,'.')    && ...
         ~strcmpi(OPT.files(ifile).name,'..')   && ...
         ~strcmpi(OPT.files(ifile).name,'info') && ...
         ~strcmpi(OPT.files(ifile).name,'.svn')
                  
         adffile = fullfile(OPT.rawdir,OPT.years(iyear).name,'geogegevens','raster'   ,OPT.sets(iset).name    ,OPT.files(ifile).name);
         texname = fullfile(           OPT.years(iyear).name,'geogegevens','raster'   ,OPT.sets(iset).name    ,OPT.files(ifile).name);
         pngname = [OPT.pngdir filesep OPT.years(iyear).name,'_geogegevens_raster','_',OPT.sets(iset).name,'_',OPT.files(ifile).name];
         
      %% load
         
         disp(['  ',num2str(ifile,'%0.3d'),' : ',texname]); %OPT.files(ifile).name])
   
         [X,Y,D,M] = arc_info_binary(adffile,'debug',0,'warning',0);
         
      %% plot
   
         clf         
         AX = subplot_meshgrid(3,1,[.02 .02 .005 .005],[.03 .03],[.7 .05 nan],[nan]);
         AX(2);noaxis
         axes(AX(1))
         pcolorcorcen(X,Y,D)
         axis equal
         axis(axis)
         hold on
         plot(L.x,L.y,'color',[.8 .8 .8])
         tickmap('xy','texttype','text','dellast',1)
         text(0,1,mktex(texname),'units','normalized','verticalalign','bot')
         text(1,0,'source: Rijkswaterstaat, plot: OpenEarth, GJdB, 2010','units','normalized','verticalalign','top','rotation',90,'fontsize',9)
         colorbarwithvtext('elevation','position',get(AX(2),'position'))
         
         b = axis;
         
         axes(AX(3))
         plot([b(1) b(2) b(2) b(1) b(1)],[b(3) b(3) b(4) b(4) b(3)],'r','linewidth',2)
         axis equal
         axis auto
         hold on
         plot(L.x,L.y,'color',[.8 .8 .8])
         set(gca,'xtick',[]);
         set(gca,'ytick',[]);
         noaxis(gca)
   
         print2screensizeoverwrite(pngname)
         close
   
      end % file KB
      end
      end

   end % set
   end
   end

end % year
end
end
