MATLAB Answers

0

Display USGS DTM using mapshow

SUSHMA MB 님이 질문을 제출함. 14 Sep 2016
최근 활동 Sally Wood 님이 댓글을 추가함. 26 Jul 2017
[germany, R] = geotiffread('srtm_germany_dtm.tif');
germany = double(germany);
figure
mapshow(germany, R);
I have also converted the matrix germany of type single into doulble. but still im getting the following error:
Error using checkRefObj (line 25)
Function mapshow expected input number 2, R, to be either a 3-by-2 referencing matrix or a scalar map raster reference object. Instead its
type was: map.rasterref.GeographicCellsReference.
Error in validateMapRasterData>parseImageInputs (line 112)
refmat = checkRefObj(mapfcnname, R, size(A), R_position);
Error in validateMapRasterData>validateImageComponent (line 92)
[A, R] = parseImageInputs(mapfcnname, dataArgs{:}, cmap, rules );
Error in validateMapRasterData (line 26)
[Z, SpatialRef] = validateImageComponent(mapfcnname, ...
Error in maprastershow (line 126)
[Z, SpatialRef, displayType, HGpairs] = ...
Error in mapshow (line 228)
h = showFcn(varargin{:});
Can anyone please help me to display the geotiff file.

  댓글 수: 0

로그인 to comment.

답변 수: 2

Kojiro Saito 님의 답변 17 Sep 2016

If you also have a tfw file, the following code should work.
[X cmap] = imread('srtm_germany_dtm.tif');
R = worldfileread('srtm_germany_dtm.tfw');
figure
X = double(X);
mapshow(X, cmap, R);
Or, do you have only a geotiff file?

  댓글 수: 2

I have only geotiff file. And still im not able to view it on MATLAB
How about using geoshow?
[X, R] = geotiffread('srtm_germany_dtm.tif');
X = double(X);
geoshow(X, R);
Let me know whether this will view your geotiff file on MATLAB.

로그인 to comment.


Brian 님의 답변 26 Jan 2017

I'm having this same problem. Using geoshow results in the same problem.

  댓글 수: 2

What is the CoordinateSystem of your DTM file? You can see by the following,
[X,R] = geotiffread('dtm.tiff');
R
If it's geographic, it shows
CoordinateSystemType: 'geographic'
I'm also having the same problem:
[bathy,R] = geotiffread('B2_rgb.tif');
figure; mapshow(bathy,R)
Gives the error:
Error using checkRefObj (line 25)
Function mapshow expected input number 2, R, to be either a 3-by-2 referencing matrix or a scalar map raster reference object. Instead its type was:
map.rasterref.GeographicCellsReference.
Whilst replacing mapshow with geoshow:
[bathy,R] = geotiffread('B2_rgb.tif');
bathy=double(bathy);
figure; geoshow(bathy,R)
Gives a different error:
Error using checkImage>checkRGBImage (line 51)
RGB images must be size M-by-N-by-3.
Error in checkImage (line 36)
RGB = checkRGBImage(A);
Error in validateTextureComponent (line 20)
dataArgs{imageIndex} = checkImage( ...
Error in validateGeoRasterData (line 24)
geofcnname, dataArgs, displayType, rules);
Error in georastershow (line 144)
validateGeoRasterData('geoshow', dataArgs, displayType);
Error in geoshow (line 276)
h = showFcn(varargin{:});
With regards to the Matlab example given for geotiffread...
[boston, R2] = geotiffread('boston.tif');
figure; mapshow(boston, R); axis image off
... my file differs in a number of ways. Firstly it is MxN x4 whilst 'boston.tif' comes out MxNx 3 (presumably the 3 RGB channels?). Secondly, R comes out as a 1x1 GeographicCellsReference whilst R2 for 'boston.tif' comes out as a 1x1 MapCellsReference. Finally, the Coordinate system type is 'geographic' compared to 'planar' in the Matlab example.
I don't know enough about these types of files to figure out which difference is causing the problem, so any advice would be gratefully received. I have tried just plotting 3 layers of my tif file but this crashes my computer!
bathy=double(bathy(:,:,2:4));
figure; geoshow(bathy,R)

로그인 to comment.



Translated by