I have a large XYZ file (300276x3, this file includes x and y coordinates (not lat/lon, but polar stereographic) and elevation z) and I'm wondering if it would be possible to convert this into a gridded dataset (n x m matrix). The xyz file can be downloaded from:
and imported in matlab by:
AIS_SEC = importdata('AIS_SEC.xyz');
I tried:
X= XYZ(:,1);
Y= XYZ(:,2);
Z= XYZ(:,3);
xr = sort(unique(X));
yr = sort(unique(Y));
gRho = zeros(length(yr),length(xr));
gRho = griddata(X,Y,Z,xr,yr')
imagesc(gRho)
Requested 300276x300276 (671.8GB) array exceeds maximum array size preference. Creation of arrays
greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size
limit or preference panel for more information.
I tried:
x = unique(XYZ(:,1)) ;
y = unique(XYZ(:,2)) ;
nx = length(x) ;
ny = length(y) ;
D = reshape(XYZ(:,3),[ny,nx]) ;
H = flipud(H) ;
H = H' ;
surf(x,y,H) ;
Error using reshape
To RESHAPE the number of elements must not change.
I can now plot the nx3 file with scatter3 (see image)
scatter3(XYZ(:,1),XYZ(:,2),XYZ(:,3),2,XYZ(:,3)) ;
colorbar
But I'd like to do it with imagesc. Hence, I would like to convert the nx3 file into a nxm matrix (in raster/gridded format) and as en extra I would like it as a geotiff file for use in QGIS.
Thanks!
3 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_992831
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_992831
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_1025113
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_1025113
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_1190303
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/486648-convert-large-xyz-file-into-grid#comment_1190303
Sign in to comment.