function [xi,yi,zi] = rectified_surface(survey_dir)
%%% Script needs:
% oetsettings
% Vlugtenburg scripts folder added to path!

% Survey 2
% walks = Read_XYZ('walking\raw\2009_07_17\Products\XYZ_RDNAP.txt');
walks = Read_XYZ(survey_dir);

if 1 %% rotate yes(1) or no(0)
    x0=69141.4936;      %% coordinates northern Jarkus pole (exracted from the 5 Aug 2009 survey)
    y0=447448.7293;
    theta0 =-131.65534968173412+90;  %% angle ref line (fence) in add_surveygrid!
    
    Xrect = -walks.data(:,1).*sind(theta0) + walks.data(:,2).*cosd(theta0);
    Yrect =  -walks.data(:,1)*cosd(theta0) - walks.data(:,2)*sind(theta0);
end


if 1
    figure
    
    scatter(Xrect,Yrect,3,walks.data(:,3))
    hold on
    %add_surveygrid
    axis image
    % xlim([6.69e4 6.946e4])
    % ylim([4.459e5 4.484e5])
    xlabel('RD coordinates [10^3 m]');
    ylabel('RD coordinates [10^3 m]');
    colorbar
    title('Survey Grid');
end
%interpolate
if 1
    [xi,yi] = meshgrid(3.797e5:(3.803e5-3.797e5)/100:3.803e5,...
        2.455e5:(2.460e5-2.455e5)/100:2.460e5);
    zi = griddata(Xrect,Yrect,walks.data(:,3),xi,yi);
    
        figure;pcolor(xi,yi,zi)
        shading interp
end
