【发布时间】:2019-10-22 05:56:39
【问题描述】:
我有一个大的 XYZ 文件(300276x3,该文件包括 x 和 y 坐标(不是纬度/经度,而是极坐标)和海拔 z),我想知道是否可以将其转换为网格数据集(n x m 矩阵)。 xyz 文件可以从以下位置下载:
并通过以下方式导入matlab:
AIS_SEC = importdata('AIS_SEC.xyz');
我试过了:
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.
我试过了:
% 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.
我现在可以用 scatter3 绘制 nx3 文件(见图)
scatter3(XYZ(:,1),XYZ(:,2),XYZ(:,3),2,XYZ(:,3)) ;
colorbar
但我想用 imagesc 来做。因此,我想将 nx3 文件转换为 nxm 矩阵(光栅/网格格式),另外我希望它作为一个 geotiff 文件在 QGIS 中使用。
谢谢!
【问题讨论】:
-
"我尝试了一些类似 meshgrid 的东西,但 Matlab 一直告诉我生成的网格太大" 请展示您尝试过的内容,以及您想要的小示例达到。
-
@rinkert 我更新了一些东西。希望现在更清楚了。