In MATLAB I have written the code:


but there was error:

  • geotiffwrite>validateR (line 847) 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.
  • geotiffwrite>validateInputs (line 348) R = validateR(R, size(A), hasColorMap, type);
  • geotiffwrite (line 238) [filename, A, cmap, R, Params] = validateInputs(filename, A, cmap, R, Params);
  • You should include the description of what you are doing in the body of the question, please don't continue directly on from the title. – nmtoken Dec 8 '17 at 8:45
  • sorry. I want to write a tif to a geotiff. – xiaojuan liu Dec 8 '17 at 8:50
  • Please edit the question, please don't use comments to add detail of what you want to do or try. – nmtoken Dec 8 '17 at 8:54

Try the following code:
[ImageTemp, R] = geotiffread('filename.tif'); clear ImageTemp; info = geotiffinfo(filename); geotiffwrite(IMG,outputimage,R,'GeoKeyDirectoryTag',info.GeoTIFFTags.GeoKeyDirectoryTag)

where filename is your image(image base) & outputimage is your image that you will want write it with tif format & IMG is out put image name

for use geotiffwite on matlab you need to spatial reference detailes for example: datum, projection & ... . this detailes there is on a file with (.tfw) format that is hidden. for get it information we use ( info). I tryed it code and worked for me.

  • Please edit your post to include more details. Why does this code work? – Fezter Aug 29 '18 at 2:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.