Hi!
I understand that you have created a geotiff file and saved it using the "geotiffwrite" function. The spatially referenced matrix "R" was created using the "georasterref" function. However, when you try to read the file and display its data using the "mapshow" function, an error occurs.
The error you are encountering indicates that there might be an issue with how the file was written or with the spatial reference matrix. To resolve this, you can try creating the reference matrix using either the "MapCellsReference" or "MapPostingsReference" type. For example.
R = georefpostings([0 1], [0 1], size(imageData));
You can refer to the following link to understand the expected format of the "R" matrix for the "mapshow" function and explore different functions available to create the "R" matrix:
As a workaround, you can try using the "geoshow" function instead of "mapshow" to display the data from the geotiff file. To understand how to use "geoshow" and its functionality, you can refer to the following link:
In the below provided code, the "geoshow" function is used to display the data from the geotiff file, and it does not produce any errors.
% Generate random image data
imageData = rand(100, 100);
% Define spatial reference information
R = georasterref('RasterSize', size(imageData), 'LatitudeLimits', [0 1], 'LongitudeLimits', [0 1]);
% Create GeoTIFF file
filename = 'random_image.tif';
geotiffwrite(filename, imageData, R);
% Display confirmation message
disp(['GeoTIFF file saved as: ' filename]);
% Read the GeoTIFF file
[A, R] = readgeoraster(filename);
% Display the GeoTIFF image using geoshow
figure
geoshow(A, R, "DisplayType","mesh");
Hope this helps.