Hi,
When I try to read multi layer geotiff images using geotiffread, I receive an error that the multiple image in that geotiff are not of the same size.
This is how I tried to read the image
[I,R]=geotiffread('filename.tif')
or
[I,R]=geotiffread('filename.tif',1) % to force read only the first layer.
I can read them just fine with the imread and using the imfinfo I manually create R myself. But I think this is a bug that needs to be addressed in geotiffread.
MATLAB is correct about the multiple images not having the same size. The fact is that those other images/layers are the pyramid or overview layers. However, that does not make any sense that geotiff read not be able to read the specified layer from the file and complaining about it.
Here is the error:
Error using geotiffinfo>readinfo (line 261)
Multiple images exist in the file and their sizes are different.
Error in geotiffinfo (line 241)
info = readinfo(filename);
Error in geotiffread (line 78)
info = geotiffinfo(filename);

8 commentaires

Tim Bartholomaus
Tim Bartholomaus le 2 Avr 2015
I am also having this very same problem. Most geotiffs can be read just fine, but others generate errors and I can't force-read the first layer. imread and imfinfo work just fine on my 2-layer geotiff. I'm using Matlab 2015a
erikaj
erikaj le 10 Nov 2016
Modifié(e) : erikaj le 10 Nov 2016
Were either or you able to resolve this problem? If so, please let me know. Thank you.
Einat
Einat le 14 Juin 2017
I have this problem too! Did anyone manage to solve it?
Shad Oneel
Shad Oneel le 16 Fév 2018
I have this problem too. Argh.
chengjuan gong
chengjuan gong le 21 Mar 2018
I have this problem too, please let me know the answer if anyone had solved it.Thank you!
Yu Jiang
Yu Jiang le 3 Avr 2018
Modifié(e) : Walter Roberson le 3 Avr 2018
It's because the photoscan exported images contain multiple layers with different sizes. See the link for detailed solution. https://cosmojiang.wordpress.com/2018/04/02/matlab-geotiffread-for-multiple-layers/
@ Yu Jiang Thanks for posting your workaround. Even with your changes, I still got an error, which I fixed by implementing the following code into geotiffinfo.m (search for first line and a half to find relevant section)
tagName = 'GeoKeyDirectoryTag';
if isfield(geoTiffTags, tagName) & tagName~='GeoKeyDirectoryTag' %add this second part after the & symbol
[geoTiffTags.(tagName)] = deal(translateGeoKeyDirectoryTag(geoTiffTags(1)));
end
davide verdicchio
davide verdicchio le 20 Déc 2019
I tried also with the following link, but when I try to modify the "Geotiffinfo" function it still gives me an error.
https://cosmojiang.wordpress.com/2018/04/02/matlab-geotiffread-for-multiple-layers/
How can I solve it?

Connectez-vous pour commenter.

Réponses (3)

Matthew Cooper
Matthew Cooper le 22 Nov 2016

1 vote

I had the same problem with a DEM I generated using Agisoft Photoscan software. To solve the problem, I loaded the DEM into ArcMap and then I exported the DEM. This is an annoying work around but it solved the problem for me - I was able to read the exported DEM into Matlab. I have actually used this workaround to solve a few other incompatibility issues between various geospatial analysis software and Matlab, namely issues involving "no data" values. Arc does something when it exports the DEM that makes the exported DEM compatible with geotiffread.

1 commentaire

jian liu
jian liu le 24 Mar 2017
Ihe another band in the tif file is mask_file or external rectangle consist of 0 or 255.

Connectez-vous pour commenter.

Daan Poppema
Daan Poppema le 4 Sep 2019

0 votes

I had the same problem with DEM's from Agisoft Photoscan/Metashape. Unfortunately the solutions above did not work for me. In the end, my workaround is changing the settings in Agisoft during DEM export. If you deselect 'write tiled TIFF' (for the pyramid scheme) and deselect 'Generate TIFF overviews' in Agisoft, the resulting tiff only contains 1 image and you don't get an error in Matlab.
Andrew Sole
Andrew Sole le 22 Oct 2020

0 votes

It seems that readgeoraster https://uk.mathworks.com/help/map/ref/readgeoraster.html gets around the same error which I encountered when attempting to load a geotiff from the ITS_LIVE ice velocity dataset: https://nsidc.org/apps/itslive/

1 commentaire

Alex
Alex le 3 Nov 2020
This is because the ITS_LIVE .tif files are cloud optimized geotiffs that have multiple resolutions embeded into a single file

Connectez-vous pour commenter.

Produits

Commenté :

le 3 Nov 2020

Community Treasure Hunt

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

Start Hunting!

Translated by