Display USGS DEM using geotiffread and mapshow

47 views (last 30 days)
Hi, I'm trying to use USGS DEMs in MATLAB but after reading it in with geotiffread, mapshow produces an error. Based on the documentation, I tried
[A, R] = geotiffread('NED_10340081')
figure
mapshow(A, R);
but I get
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{:});
My matrix A is of type single...is that the problem? and how do I fix this? Thanks
  1 Comment
Em
Em on 24 Mar 2014
I encounter this same issue using 2013b. My file is from the Global Land Survey DEM (<http://glcf.umd.edu/data/glsdem/)>. I read the file using:
[B, R] = geotiffread('/home/mrd20/matlab/geo/data/GLSDEM_n040e060');
After applying the fix above to B (convert to double), I then find mapshow objecting to 'R' which has the type:
map.rasterref.GeographicCellsReference
where as mapshow expects either a 3-by-2 referencing matrix or a scalar map raster reference object.
I find that geoshow does not list an error condition, but creates a 'blank' plot having the correct lat/lon info on the axes.
I've been working through geospatial webinars, but working with non-WMD resources is not given attention there.
Cheers, ~ Em

Sign in to comment.

Accepted Answer

Dominik
Dominik on 19 May 2012
geotiffread results in a type 'single' but mapshow defaults to a 'image' that can only accept 'double' (and some other formations not including 'single'). Either A=double(A) or mapshow(A,R,'DisplayType','surface')
  1 Comment
Em
Em on 24 Mar 2014
I encounter this same issue using 2013b. My file is from the Global Land Survey DEM (<http://glcf.umd.edu/data/glsdem/)>. I read the file using:
[B, R] = geotiffread('/home/mrd20/matlab/geo/data/GLSDEM_n040e060');
After applying the fix above to B (convert to double), I then find mapshow objecting to 'R' which has the type:
map.rasterref.GeographicCellsReference
where as mapshow expects either a 3-by-2 referencing matrix or a scalar map raster reference object.
I find that geoshow does not list an error condition, but creates a 'blank' plot having the correct lat/lon info on the axes.
I've been working through geospatial webinars, but working with non-WMD resources is not given attention there.

Sign in to comment.

More Answers (1)

Wanda Crupa
Wanda Crupa on 13 Oct 2019
You can also show geotiff images using the imagesc(geotiff) command.However, this does not display them using geographic coordinates as needed for a map, but is great for cheking any image processing of raster data.
Example:
[geotiff1, R] = geotiffread('my_geotiff.tiff');
imagesc(geotiff1);
raster.png

Products

Community Treasure Hunt

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

Start Hunting!