2

I've been prototyping some processing techniques for SAR images in Matlab. This requires importing a GeoTIFF file, and then exporting a file with modified data but the same spatial reference. I have no issue importing the GeoTIFF file, but when I try to write a GeoTIFF file using the code:

    [input_data, reference] = geotiffread(filename);
    info = geotiffinfo(filename;
    geotiffwrite('output.tif', output_data, reference, 'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag');

Matlab throws up the following error:

Error using geotiffwrite (line 257) The referencing matrix or object supplied to function GEOTIFFWRITE specifies that the associated raster is rotated or skewed with respect to the projected coordinate system. Function GEOTIFFWRITE does not support this geometry.

It appears that this is caused by the fact that my image is rotated within a UTM coordinate system. I'm not entirely sure why this would be an issue, given that I experienced no issues with reading the data into Matlab. I was wondering if anyone knows of any way to resolve this issue or work around this apparent constraint.

UPDATE:

I've tried using Matlab's mapshow function to display my data (I've previously only displayed the image data without georeferencing). This results in the following figure:

enter image description here

This figure is also not rotated with respect to its UTM coordinate system, which suggests that Matlab isn't accounting for the rotation in its map display functions as well.

SECOND UPDATE:

I've taken a look through the GeoTIFF tags in Matlab, and it does seem that the data needs to undergo an affine transformation, which is where my issue seems to be coming from. So the transformation is defined in the GeoTIFF file I'm reading into Matlab. I'm not sure why Matlab can't just copy the tags defining the transformation into the output file, but at the moment, I am exploring two possibilities:

  1. Applying the affine transformation in Matlab, padding it with nodata values, and then saving the transformed data in the GeoTIFF format. This would require changing some of the other data tags before saving the data.
  2. Using GDAL to copy the metadata of my imported GeoTIFF file to produce the desired GeoTIFF file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.