%MONSTERPUNTEN2NC2KML
%
% plot Monsterpunten.xlsx and visualize in Google Earth
%
%  Note: it is better to save data as netCDF first and THEN plot it for Google Earth
%
% See also: MONSTERPUNTEN2NC2NC

   clear all
   
   OPT.description =  'Building with Nature HK3.2 aeolian event';
   OPT.fields      = {'Texel Hors',...
                      'Texel Westerduinen',...
                      'Bergen az',...
                      'Groote Keeten',...
                      'Wassenaar',...
                      'Schoorl'};
   OPT.colors      = {'r','g','b','c','m','y'};
   OPT.version     = '$Revision$';

%% load
   
   for ifld=1:length(OPT.fields)
   
      D(ifld)             = xls2struct('..\raw\Monsterpunten.xlsx',OPT.fields{ifld},'units',0);
      
   end

%% enrich

   for ifld=1:length(OPT.fields)

      D(ifld).n           = length(D(ifld).X);
      D(ifld).description = OPT.fields{ifld};
      D(ifld).X_units     = 'm';
      D(ifld).Y_units     = 'm';
     [D(ifld).lon,...
      D(ifld).lat] = convertcoordinates(D(ifld).X,D(ifld).Y,'CS1.code',28992,'CS2.code',4326);

   end

%% make kml

   for ifld=1:length(OPT.fields)
   
      kmlscatter(D(ifld).lat  (:),...
                 D(ifld).lon  (:),...
                 D(ifld).label(:),...
                    'units','',...
                 'colorMap',@(m) colormap_white(m),...
               'colorSteps',1,...
                'long_name',[OPT.fields{ifld},': label '],...
              'markerAlpha',1.0,...
                 'fileName',['sheet_',num2str(ifld),'.kml'],...
                  'kmlName',D(ifld).description,...
              'description','');
              
   end                      
                         
   sourceFiles = dir('sheet_*.kml');
      
   kmlmerge_files('fileName','Monsterpunten_overview.kml',...
               'sourceFiles',{sourceFiles.name},...
               'description',OPT.description)

%% plot

   for ifld=1:length(OPT.fields)
   
      %% check
      if ifld==1
      L = nc2struct('http://opendap.deltares.nl:8080/thredds/dodsC/opendap/deltares/landboundaries/holland.nc');
      plot   (L.lon,L.lat,'color',[.5 .5 .5])
      hold    on
      end
      
      plot   (D(ifld).lon,D(ifld).lat,OPT.colors{ifld},'linewidth',2)
      tickmap('ll')
      
   end                      
   
%% make netCDF

   Monsterpunten2nc

% EOF