clear all; close all; clc
outputfile = 'D:\OpenEarthRawData\trunk\vanoordboskalis\waterweg\scripts\Waterweg.nc';

%% readvalues
t = nc_varget(outputfile, 't'); 
x = nc_varget(outputfile, 'x');
y = nc_varget(outputfile, 'y');
for i = 0:size(t,1)-1
    z = nc_varget(outputfile, 'z', [i 0 0], [1  size(y,1) size(x,1)]);
    figure(1);clf
    xs = find(sum(~isnan(z),1)~=0);
    ys = find(sum(~isnan(z),2)~=0);
    minx = xs(1);
    maxx = xs(end);
    miny = ys(1);
    maxy = ys(end);
    stepsize = 2;
    surf(x(minx:stepsize:maxx)', y(miny:stepsize:maxy), z(miny:stepsize:maxy, minx:stepsize:maxx)); shading flat
    hold on;
    box on
    grid on
    xlabel('x-coordinate [m] (Amersfoort RD - New)')
    ylabel('y-coordinate [m] (Amersfoort RD - New)')
    zlabel('elevation [m] (datum: NAP = 0)')
    title({'NetCDF demonstration: Waterweg data';datestr(t(i+1))})
    axis equal
    colorbar
    view(2)
    pause
end

%     set(gca, 'cameraposition', [67280 449805 40.6286])
%     set(gca, 'cameraposition', [-64625.4 447787 11.3365])
%
%     printFigure(gcf, [strtok(outputfile,'.') '.png'],'overwrite','-dpng')
