%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,'..')
   
   clf
   AX = subplot_meshgrid(1,1,[.025 .01],[.01 .025]);
   
   disp([num2str(iyear,'%0.3d'),' : ',OPT.years(iyear).name])

  %S = arc_shape_read(...)
   S = shaperead(fullfile(OPT.rawdir,OPT.years(iyear).name,'productinfo','bladindeling',[OPT.years(iyear).name,'_index.shp']));

   for is=1:length(S)
      plot(S(is).X,S(is).Y)
      hold on
   end   

   plot(L.x,L.y,'color',[.8 .8 .8])
   axis equal
   tickmap('xy','texttype','text','dellast',1)
   text(0,1,[' ',mktex(OPT.years(iyear).name)],'units','normalized','verticalalignment','top')
   grid on
   text(1,0,' source: Rijkswaterstaat, plot: OpenEarth, GJdB, 2010','units','normalized','verticalalign','bot','rotation',90,'fontsize',9)

   print2screensizeoverwrite([OPT.years(iyear).name,'.png'])

   for is=1:length(S)
      text(nanmean(S(is).X),nanmean(S(is).Y),strtrim(S(is).BLADNR),'rotation',45,'fontsize',9)
   end   

   print2screensizeoverwrite(['with_names',filesep,OPT.years(iyear).name,'_with_names.png'],2048)
   close

end % year
end
end
