MATLAB: How i can build a Digital Elevation Model at a specific resolution from .xyz file

dempoint cloud

I need to produce Digital Elevation Models at different resolution (0.01 m, 0.05 m, 0.1 m) from a point cloud dataset (in .xyz format).
Then i would like to plot the obtained DEMs in order to visualize the differences at the different resolution.
Finally, i would like to save the DEMs at different resolution as .xyz file.
I have xyz data in local metric coordinates (not geographic) and i loaded them as below:
data = load('pointcloud_3D.xyz');
x = data(:,1);
y = data(:,2);
z = data(:,3);
clear data;
zzero=z-min(z);"
Thank You in advance for your help.

Best Answer

It depends on whether your data is grdded or not gridded. Let A be your m*3 data. Check below options to proceed:
x = A(:,1) ; y = A(:,2) ; z = A(:,3) ;
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
surf(X,Y,Z)
% And use interp2 for interpolation.
%%unstructured
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)
% And use scatteredinterpolant for interpolation.