Convert large xyz file into grid

34 visualizaciones (últimos 30 días)
Yoni Verhaegen -WE-1718-
Yoni Verhaegen -WE-1718- el 21 de Oct. de 2019
Comentada: Sara el 7 de Dic. de 2020
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:
% Get coordinate vectors
x = unique(XYZ(:,1)) ;
y = unique(XYZ(:,2)) ;
% dimensions of the data
nx = length(x) ;
ny = length(y) ;
% Frame matrix of grid
D = reshape(XYZ(:,3),[ny,nx]) ;
% flip matrix to adjust for plot
H = flipud(H) ;
% Transpose the matrix
H = H' ; % Check if is required
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 comentarios
Chad Greene
Chad Greene el 26 de Sept. de 2020
Have you seen my xyz2grid function? I think it'll do what you want.
Sara
Sara el 7 de Dic. de 2020
Hi, where is the function? i did not see it in the MATLAB helo. I also I did net know where I can the download

Iniciar sesión para comentar.

Respuestas (2)

Chad Greene
Chad Greene el 26 de Sept. de 2020
Try my xyz2grid function. It's fast, easy to use, and one of the examples in that documentation link shows how to grid up an Antarctic dataset just like yours.

Bibhu Das
Bibhu Das el 21 de Oct. de 2019
If its a 2D data try to figure out min. and max. of X and Y. Then reshape the z column so that size z is equal to 300276. Finally you can contour it.

Categorías

Más información sobre Glaciology en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by