How can I load a tif file and save it again with the same parameters as before?

4 views (last 30 days)
I want to load a tif file and save it again, but the saved file is not the same like the original file. helgoland_bathy.tif is a bathymetry map with georeferenced coordinates. The problem is that the second file has the wrong entries in the info parameter. Like PixelScale, RefMatrix and so on. It is possble to get all ifnormation from the tif file and save this again as a new tif with the identical information?
infilename = 'helgoland_bathy.tif';
[A,R] = readgeoraster(infilename);
info = geotiffinfo(infilename);
geoTags = info.GeoTIFFTags.GeoKeyDirectoryTag;
geotiffwrite('helgoland_bahty_2.tif',A,R,'GeoKeyDirectoryTag',geoTags)

Answers (1)

Gagan Agarwal
Gagan Agarwal on 7 Sep 2023
Hi Jonas Müller
The problem lies in the size of the image. MATLAB has a limitation where it can only save images in the traditional TIFF format that are up to 2^32-1 bytes in size, due to its 32-bit restriction. While MATLAB's version of libtiff can handle and read 64-bit TIFF images, it cannot write them.
For further details and additional information, you can consult the following blog: http://blogs.mathworks.com/steve/2013/08/07/tiff-bigtiff-and-blockproc/

Tags

Community Treasure Hunt

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

Start Hunting!