Read/write georeferenced image
21 views (last 30 days)
Massimo Zanetti on 28 Sep 2022
Hi, here I am wondering why this simple operation of reading a georeferenced .tif image and writing some results in the same georeferenced framework is so difficult. Here is my example:
[A,R] = readgeoraster("input_image.tif");
O = f(A) %any operation you like
This gives the error:
Error using geotiffwrite
The input, R, is a map.rasterref.MapCellsReference object indicating that you are working in a projected coordinate system. If so, then specify a projected coordinate system by setting the appropriate values for the 'CoordRefSysCode' or 'GeoKeyDirectoryTag' optional parameters.
But the input image includes the Coordinate Reference System Code (which is EPSG:32632), and the geotiffinfo function confirms that, as I have among other values: PCS: WGS 84 / UTM Zone 32N, which is the same as EPSG:32632.
So, do we have two Matlab functions incompatible each other? How am I supposed to automatically save the result without manually input 'CoordRefSysCode',32632 to the geotiffwrite function?
Kevin Holly on 28 Sep 2022
Can you try this below?
[A,R] = readgeoraster('input_image.tif');
O = A*2; %any operation you like
info = geotiffinfo('input_image.tif');
key = info.GeoTIFFTags.GeoKeyDirectoryTag;