我的目标提取火山轮廓,其中一步是根据DEM,将火山轮廓理想化成一个圆锥,使圆锥有DEM的坐标系统,并且生成圆锥的Aspect图,半径和高程是根据DEM获取的。裁剪的影像小的时候能运行出来,但是影像大了一点就报错,请问具体要怎么改?
出错提示:
请求的 43200x64800 (20.9GB)数组超过预设的最大数组大小。创建大于此限制的数组可能需要较长时间,并且会导致 MATLAB 无响应。
出错 Untitled2_2>createConeWithDEM (第 15 行)
dem = double(dem);
出错 Untitled2_2 (第 10 行)
createConeWithDEM(dem_file, r, h, n, num_segments, new_dem_file, new_aspect_file);
DEM在这:链接:https://pan.baidu.com/s/1RmzktqFV6HvtZIxIcqFYZg
提取码:1111
clc;
clear all;
dem_file = 'D:\数据\1\extract_dtm.tif';
r = 2300;
h = 331;
n = 50;
num_segments = 10;
new_dem_file = 'D:\数据\1\Cone_DEM1.tif';
new_aspect_file = 'D:\数据\1\Cone_Aspect1.tif';
createConeWithDEM(dem_file, r, h, n, num_segments, new_dem_file, new_aspect_file);
function createConeWithDEM(dem_file, r, h, n, num_segments, new_dem_file, new_aspect_file)
% 读取DEM数据
[dem, R] = geotiffread(dem_file);
dem = double(dem);
[rows, cols] = size(dem);
% 获取原始DEM文件的GeoTIFFTags
dem_info = geotiffinfo(dem_file);
geo_key_directory_tag = dem_info.GeoTIFFTags.GeoKeyDirectoryTag;
% 创建新的DEM文件和坡向文件
cone_dem = zeros(rows, cols);
aspect_dem = zeros(rows, cols);
% 计算圆锥体顶点坐标
cone_x = round(cols / 2);
cone_y = round(rows / 2);
% 循环遍历DEM的每个像素点
for row

在使用MATLAB进行火山轮廓处理时,根据DEM数据生成圆锥模型,当影像尺寸增大导致超出预设最大数组限制而报错。问题出现在将DEM转换为double类型时。解决方案可能包括优化内存管理,分块处理数据,或者使用支持大数据处理的工具或语言。
最低0.47元/天 解锁文章
872





