【问题标题】:reading and displaying USGS NED DEM读取和显示 USGS NED DEM
【发布时间】:2012-05-13 22:00:28
【问题描述】:

我正在尝试在 MATLAB 中使用 USGS DEM,但在使用 geotiffread 读取它后,mapshow 会产生错误。根据文档,我尝试了

[A, R] = geotiffread('NED_10340081')
figure
mapshow(A, R);

但我明白了

Error using mapshow
Expected input number 1, I or X or RGB, to be one of these types:

uint8, uint16, double, logical

Instead its type was single.

Error in validateMapRasterData>parseImageInputs (line 109)
validateattributes(A, {'uint8', 'uint16', 'double', 'logical'}, ...

Error in validateMapRasterData>validateImageComponent (line 93)
[A, R] = parseImageInputs(mapfcnname, dataArgs{:}, cmap, rules );

Error in validateMapRasterData (line 27)
[Z, SpatialRef] =  validateImageComponent(mapfcnname, ...

Error in maprastershow (line 127)
[Z, SpatialRef, displayType, HGpairs] = ...

Error in mapshow (line 231)
h = showFcn(varargin{:});

我的矩阵 A 是单一类型的...这是问题所在吗?我该如何解决这个问题? 这是 DEM http://snowserver.colorado.edu/pub/fromDominik/NED_10340081.zip 的下载链接 谢谢 PS我在http://www.mathworks.com/matlabcentral/answers/38255-display-usgs-dem-using-geotiffread-and-mapshow交叉发布了这个

【问题讨论】:

    标签: matlab mapping geotiff


    【解决方案1】:

    指定 DisplayType 是必要的,因为 Matlab 将“图像”与连续栅格数据区分开来。 Matlab 有一个完整的图像处理工具箱和一个映射工具箱,每个工具箱具有不同的功能,它们通常是互补的,但来自不同的开发背景。 Matlab 支持逻辑、uint8、uint16 和双精度类类型的“图像”,以及单精度和双精度的栅格(网格)数据。

    您使用 'DisplayType','surface' 的解决方案也仅适用于您的情况,因为您有“单一”数据。例如,如果您在 ArcGis 中创建了一个 geotiff 图像,然后尝试将其读入 Matlab,它将以 int16 的形式出现,并且在尝试使用 mapshow 或 geoshow 时会出现相同的错误,但 'DisplayType','surface ' 在这种情况下不起作用,因为 DisplayType 不接受 int16。您转换为双精度的解决方案更通用。

    【讨论】:

      【解决方案2】:

      我终于明白了。 geotiffread 给出了一个矩阵类型 'single' 但 mapshow 默认显示一个 image ,它只接受类型 'double' (和其他一些)。所以这里的解决方案是:

      A=double(A);
      

      mapshow(A,R,'DisplayType','surface');
      

      【讨论】:

      • 我注意到它不是 or 而是 and。您还介意解释为什么需要指定 DisplayType 吗?
      • 我真的不知道比我写的更多,但我的理解是 mapshow 默认为 DisplayType image 它期望矩阵类型以外的东西,因此错误消息我发布了:Expected input number 1, I or X or RGB, to be one of these types: uint8, uint16, double, logical 我以为我的矩阵类型单一可以与“DisplayType”选项“表面”一起使用,但已经有几个星期了,所以我不得不再看一遍,而且我已经远离我的主计算机了现在
      猜你喜欢
      • 2014-10-15
      • 2019-06-18
      • 1970-01-01
      • 2019-08-17
      • 2012-07-18
      • 2018-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多